-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: optimize iter matching #7702
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
Conversation
GNU testsuite comparison:
|
src/uu/chroot/src/chroot.rs
Outdated
@@ -54,19 +54,20 @@ struct Options { | |||
/// The `spec` must be of the form `[USER][:[GROUP]]`, otherwise an | |||
/// error is returned. | |||
fn parse_userspec(spec: &str) -> UResult<UserSpec> { | |||
match &spec.splitn(2, ':').collect::<Vec<&str>>()[..] { | |||
let mut parts = spec.splitn(2, ':'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be cleaner to use split_once
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cakebaker thx, good idea. The issue that I uncovered though is that the ChrootError::InvalidUserspec
will never be produced -- all userspec values are valid?!
f255cc7
to
7c722ae
Compare
GNU testsuite comparison:
|
GNU testsuite comparison:
|
@sylvestre @cakebaker so what's the proper solution for the bug uncovered by this PR, i.e. that |
b771d98
to
27f41a5
Compare
GNU testsuite comparison:
|
I don't think I'm able to get anything but "invalid user" or "invalid group" from GNU here, so it's probably fine to let the group parsing later deal with it. |
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
GNU testsuite comparison:
|
There is no need to allocate a vector when matching a sequence of items
GNU testsuite comparison:
|
InvalidUserspec
error