-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fold: Adding combining character support #9328
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
Conversation
CodSpeed Performance ReportMerging #9328 will degrade performances by 2.81%Comparing Summary
Benchmarks breakdown
Footnotes
|
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
src/uu/fold/src/fold.rs
Outdated
| let mut next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len()); | ||
|
|
||
| // Include combining characters with the base character | ||
| while let Some(&(_, next_ch)) = iter.peek() { | ||
| if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 { | ||
| iter.next(); | ||
| next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len()); | ||
| } else { | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can set next_idx after the loop as you don't use it in the loop.
| let mut next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len()); | |
| // Include combining characters with the base character | |
| while let Some(&(_, next_ch)) = iter.peek() { | |
| if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 { | |
| iter.next(); | |
| next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len()); | |
| } else { | |
| break; | |
| } | |
| } | |
| // Include combining characters with the base character | |
| while let Some(&(_, next_ch)) = iter.peek() { | |
| if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 { | |
| iter.next(); | |
| } else { | |
| break; | |
| } | |
| } | |
| let next_idx = iter.peek().map(|(idx, _)| *idx).unwrap_or(line_bytes.len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much cleaner, thanks!
cakebaker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you have seen it: the CI shows some trivial clippy issues.
|
GNU testsuite comparison: |
Kudos, and thanks for your PR! |
Been looking at how I can contribute to getting some of the tests to pass, working on this bin and it seems like adding this is a simple fix for the main fold test. The handling zero tests seem like they require a relatively major rework