uniq: accept a repeated -D/--all-repeated, last one wins - #13898
uniq: accept a repeated -D/--all-repeated, last one wins#13898AlejandroCoronadoN wants to merge 1 commit into
Conversation
Merging this PR will degrade performance by 0.1%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | du_summarize_balanced_tree[(5, 4, 10)] |
16.3 ms | 16.9 ms | -3.3% |
| ⚡ | Simulation | ls_recursive_balanced_tree[(6, 4, 15)] |
120.7 ms | 117 ms | +3.21% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing AlejandroCoronadoN:fix-uniq-repeated-all-repeated (67e88c1) with main (d8bee62)
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. ↩
| .default_missing_value("none") | ||
| .require_equals(true), | ||
| .require_equals(true) | ||
| // GNU uniq accepts a repeated -D/--all-repeated and uses the last |
There was a problem hiding this comment.
not sure we need 3 lines comment here
please make it shorter
GNU uniq accepts -D/--all-repeated given more than once and uses the last occurrence. clap rejected the second one, so a script mixing the short -D and the long --all-repeated form failed with "cannot be used multiple times". Add overrides_with so a repeat overrides the earlier value instead of erroring.
250e71b to
67e88c1
Compare
|
Thanks! Shortened the comment to a single line. |
|
Binary size comparison: |
|
GNU testsuite comparison: |
Problem
Passing
-D/--all-repeatedmore than once fails:-Dand--all-repeatedare the same option, and clap rejects the repeat. GNUuniqaccepts a repeated option and uses the last occurrence, so a script thatmixes the short and long form works there but fails here.
Fix
Add
.overrides_with(options::ALL_REPEATED)so a later occurrence overrides anearlier one, matching GNU.
Verification
Output matches GNU coreutils (
guniq) exactly. Added a regression test; thefull
test_uniqsuite passes andcargo fmt/cargo clippyare clean.