Rm no abbreviation no preserve root#10205
Conversation
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 17.36%
Performance Changes
Comparing Footnotes
|
By checking later we can reuse the result of looking up the clap flag. Since this is a map lookup it's relatively inefficient so reusing the previous lookup should improve benchmark in most cases.
|
GNU testsuite comparison: |
|
Hmm |
|
This way i would produce more overhead at the parsing stage though that will be run everytime, while the way it is right now the iteration over all args only occurs if at the parsing stage it was determined no preserve mode was active, right? Also using matches.get_flag() also is just an iteration over all "valid args" as far as i see, so introducing the --no-preserve-roo (without t) makes the clap get_matches have a bigger overhead and doesn't save any runtime cost later on. Please tell me if i have somewhere a wrong understanding how clap works. |
|
No, because the parser is already trying to match no preserve root, so clap will optimize the parsing. , you're already adding overhead with trying to get the match every time. |
|
As soon as i add another arg as you proposed clap starts enforcing the correct spelling but the error Messages are the long ones from clap itself. `❯ ./target/debug/rm --no-pre l tip: a similar argument exists: '--no-preserve-roo' Usage: rm [OPTION]... FILE... For more information, try '--help'. Also trying to use a value_parser that always returns an Error produces a different error Message by clap `❯ ./target/debug/rm --no-pre l For more information, try '--help'.` So if we want a clean GNU style error message of just 'you may not abbreviate the --no-preserve-root option' i think we have to parse this manually apart from the clap library unfortunately. |
|
Oh, okay. if that's the case, you should add the no-preserve-roo flag and make the check after parsing. If it is present, just throw an error. That way we get most performance |
|
GNU testsuite comparison: |
…racters are present
|
GNU testsuite comparison: |
|
@sylvestre the failing Android test seems to be failing for all other PR's too (and on main too). So it looks to me not to be caused by my changes for this PR |
|
yeah, just ignore it :) |
--------- Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
--------- Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Fix: #10188
Added a runtime check that --no-preserve-root is literal and was not abbreviated.
regression tests are included.