Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use One Pass in Duration Parsing #1866

Draft
wants to merge 1 commit into
base: fix-order-valid-for
Choose a base branch
from

Conversation

pavelbrm
Copy link
Contributor

@pavelbrm pavelbrm commented Jun 22, 2023

Summary

This PR speeds up the ISO duration parsing by ~200ns (did benchmark the change).

Previously the code would run the regexp twice against the same string - one to determine whether where is a match, and then to get the actual match. Under the hood, both methods use the same low level implementation, and FindStringSubmatch is also capable of indicating whether there was a match. Namely, if the result of a call to FindStringSubmatch was strictly nil, that means no matches found. Hence the change – match a given string against the pattern only once.

This is a follow up to #1865.

Type of Change

  • Product feature
  • Bug fix
  • Performance improvement
  • Refactor
  • Other

Tested Environments

  • Development
  • Staging
  • Production

Before Submitting

  • Does your code build cleanly without any errors or warnings?
  • Have you used auto closing keywords?
  • Have you added tests for new functionality?
  • Have validated query efficiency for new database queries?
  • Have documented new functionality in README or in comments?
  • Have you squashed all intermediate commits?
  • Is there a clear title that explains what the PR does?
  • Have you used intuitive function, variable and other naming?
  • Have you requested security / privacy review if needed
  • Have you performed a self review of this PR?

@pavelbrm pavelbrm self-assigned this Jun 22, 2023
@pavelbrm pavelbrm marked this pull request as ready for review June 22, 2023 08:16
@pavelbrm pavelbrm marked this pull request as draft June 22, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant