unexpand: accept a blank as a tab-list separator like GNU - #14057
unexpand: accept a blank as a tab-list separator like GNU#14057AlejandroCoronadoN wants to merge 1 commit into
Conversation
Merging this PR will improve performance by 3.84%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | du_wide_tree[(5000, 500)] |
20.5 ms | 19.8 ms | +3.84% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing AlejandroCoronadoN:unexpand-space-tab-separator (7c49a86) with main (ec8adb5)
Footnotes
-
50 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
GNU testsuite comparison: |
| } | ||
|
|
||
| /// Decide whether the character is either a space or a comma. | ||
| fn is_space_or_comma(c: char) -> bool { |
There was a problem hiding this comment.
Not a useful function. Please remove it and write code directly.
2a16155 to
80248df
Compare
|
Good point, removed the helper and inlined it as |
|
GNU splits on blank, so a literal TAB is a valid separator too - s.split([' ', '\t', ',']). expand's is_space_or_comma has the same gap; worth fixing both here. |
80248df to
7c49a86
Compare
|
Good catch, added the tab so the split is now |
GNU
unexpandaccepts both a comma and a blank between tab stops in-t/--tabs, sounexpand -t '2 3'behaves likeunexpand -t '2,3'. uutils only splits on a comma, so the space form is rejected:uutils' own
expandalready accepts both separators via anis_space_or_commahelper; onlyunexpandwas inconsistent. This splits the tab list on a space or a comma too, mirroringexpand. Verified byte for byte against GNUunexpandin the C locale for'2 3',' 2 3','2 3','2, 3'and'1 4 7'; invalid values like-t xstill error as before.