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

Simplify date parser #4143

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

CrazyboyQCD
Copy link
Contributor

  • Avoid allocation if string is ascii
  • Return early if string from utf16 encoded JsString is not ascii
  • Replace Char<'_> with slice::Iter<'_, u8>
  • Add next_n_digits helper method to save calls of next_digit
  • Merge duplicate codes in matches

@CrazyboyQCD CrazyboyQCD force-pushed the simplify-date-parser branch 3 times, most recently from 6b320c6 to d82795c Compare January 24, 2025 06:30
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 64.78873% with 25 lines in your changes missing coverage. Please review.

Project coverage is 53.56%. Comparing base (6ddc2b4) to head (d430a23).
Report is 357 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/builtins/date/utils.rs 64.78% 25 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4143      +/-   ##
==========================================
+ Coverage   47.24%   53.56%   +6.31%     
==========================================
  Files         476      487      +11     
  Lines       46892    48863    +1971     
==========================================
+ Hits        22154    26172    +4018     
+ Misses      24738    22691    -2047     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me at a high level. I like the move from char to u8 ascii. I have a suggestion.

} else {
None
}
})
}

fn next_n_digits<const N: usize>(&mut self) -> Option<[u8; N]> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Use next_digit over using next_n_digits where possible.

As tempting as next_n_digits is to write, most the lengths should be relatively stable here. We can then also avoid using unsafe code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put next_digit in next_n_digits now because I found Peekable<slice::Iter> doesn't give the len of slice::Iter under serveral conditions, so the length check is useless.
But I prefer using next_n_digits as it is not that noisy here.

@nekevss nekevss requested a review from a team January 25, 2025 01:24
@nekevss nekevss added the builtins PRs and Issues related to builtins/intrinsics label Jan 25, 2025
@CrazyboyQCD CrazyboyQCD force-pushed the simplify-date-parser branch 4 times, most recently from 84bb6bb to 3cd4ac0 Compare January 25, 2025 09:56
@CrazyboyQCD CrazyboyQCD requested a review from nekevss January 26, 2025 02:05
@CrazyboyQCD CrazyboyQCD force-pushed the simplify-date-parser branch 2 times, most recently from 2b9a56c to 6014688 Compare January 28, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants