Skip to content

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

Merged
merged 4 commits into from
Apr 15, 2025
Merged

feat: optimize iter matching #7702

merged 4 commits into from
Apr 15, 2025

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Apr 8, 2025

  • There is no need to allocate a vector when matching a sequence of items.
  • This also removes an unused InvalidUserspec error

Copy link

github-actions bot commented Apr 8, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

@@ -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, ':');
Copy link
Contributor

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?

Copy link
Contributor Author

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?!

@nyurik nyurik force-pushed the iters branch 2 times, most recently from f255cc7 to 7c722ae Compare April 9, 2025 16:04
Copy link

github-actions bot commented Apr 9, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

@nyurik
Copy link
Contributor Author

nyurik commented Apr 10, 2025

@sylvestre @cakebaker so what's the proper solution for the bug uncovered by this PR, i.e. that ChrootError::InvalidUserspec is never triggered?

@nyurik nyurik force-pushed the iters branch 2 times, most recently from b771d98 to 27f41a5 Compare April 13, 2025 04:24
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@tertsdiepraam
Copy link
Member

so what's the proper solution for the bug uncovered by this PR, i.e. that ChrootError::InvalidUserspec is never triggered?

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.

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)

Copy link
Collaborator

@RenjiSann RenjiSann left a 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 👍

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/misc/sleep is no longer failing!

nyurik and others added 4 commits April 15, 2025 12:43
There is no need to allocate a vector when matching a sequence of items
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@sylvestre sylvestre merged commit 8a5a2ee into uutils:main Apr 15, 2025
69 of 70 checks passed
@nyurik nyurik deleted the iters branch April 15, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants