Repository navigation
Conversation
Merging this PR will degrade performance by 3.45%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
Binary size comparison: |
|
GNU testsuite comparison: |
|
On the CodSpeed report — I don't think this is a real regression, but here is the evidence rather than just an assertion. The change adds two string comparisons per command-line argument in Measured locally with divan, 100 samples each:
The branch is fractionally faster on median and mean, which is to say the two are indistinguishable. (Absolute numbers are higher than CodSpeed's because this machine is slower; the comparison is what matters.) Happy to acknowledge it on CodSpeed if you'd prefer, or to look again if you think the instruction-count simulation is picking up something real that wall-clock timing hides. |
5858f6e to
f843e55
Compare
|
The macOS L10n failure is (The CodSpeed flag is addressed upthread with measurements — the branch benchmarks marginally faster than |
f843e55 to
1d35765
Compare
Both walk the arguments before clap to lift out their obsolete numeric
spellings — `uniq -1` for skip-fields and `split -22` for line count.
Neither stopped at `--`, so an operand that merely looked like the
obsolete form was swallowed:
$ uniq -- -1
(reads stdin) # GNU: uniq: -1: No such file or directory
$ split -- -1
(reads stdin) # GNU: split: cannot open '-1' for reading
Track the terminator and pass everything after it through untouched.
Both walkers already tracked whether the previous argument was an
option expecting a value, so this is the same kind of state.
The wording of uniq's own open failure still differs from GNU
("Could not open -1" against "-1"), but that is unrelated: plain
`uniq nosuchfile` differs the same way on an unmodified tree.
1d35765 to
57bff21
Compare
uniqandsplitboth walk the argument list before clap to lift out their obsolete numeric spellings —uniq -1for skip-fields,split -22for line count. Neither stopped at--, so an operand that merely looked like the obsolete form was swallowed instead of being treated as a file name.uniq -- -1uniq: -1: No such file or directorysplit -- -1split: cannot open '-1' for reading: No such file or directoryFound by differential testing against GNU coreutils 9.11.
Both walkers already threaded state for "the previous argument was an option expecting a value", so the terminator is tracked the same way: once
--is seen, everything after it is passed through untouched.This is the same class of bug as #14248 (
fold), but the three implementations are separate, so this is a separate change.Testing
One regression test each. Verified they catch the bug by reverting the two source files alone — both fail, then pass with them restored.
cargo test --features "uniq,split" --no-default-features: 162 passed, 0 failed (160 pre-existing, 2 new)cargo fmt --checkandcargo clippy -p uu_uniq -p uu_split --all-targets: cleansplit -- -1now matches GNU byte for byteNoted but not touched
The wording of uniq's own open failure still differs from GNU —
uniq: Could not open -1: No such file or directoryagainst GNU'suniq: -1: No such file or directory. That is unrelated to argument parsing: plainuniq nosuchfilediffers the same way on an unmodified tree, which I checked before writing the test, so the test asserts only that-1reaches the file layer.fmthas the same--problem (fmt -- -1reads stdin where GNU tries to open-1), but it gets there differently — through a positional withallow_negative_numbers(true)rather than a pre-clap walk — so fixing it belongs in its own change rather than being bolted on here.Disclosure
Prepared with AI assistance (Claude Opus 5, via Claude Code), per the AI policy in CONTRIBUTING.md. On the GPL point raised there: expected behavior was established by running the installed GNU binaries as a black box and recording their output. I did not read GNU coreutils source. All testing above was run locally.