-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rm no abbreviation no preserve root #10205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Rm no abbreviation no preserve root #10205
Conversation
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 10.76%
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 |
Fix: #10188
Added a runtime check that --no-preserve-root is literal and was not abbreviated.
regression tests are included.