Fold: Adding combining character support#9328
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.
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.
Much cleaner, thanks!
cakebaker
left a comment
There was a problem hiding this comment.
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! |
* Adding combining character support for fold * add fullwidth to the spell ignore list * addressing comments and cargo fmt fixes * clippy fixes for test files --------- Co-authored-by: Christopher Illarionova <drydench@amazon.com> Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
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