Skip to content

Conversation

unixzii
Copy link
Contributor

@unixzii unixzii commented Nov 28, 2024

Remove the redundant pattern joining, which can reduce memory allocations during the iteration.

@unixzii
Copy link
Contributor Author

unixzii commented Aug 1, 2025

Hi @tgross35, sorry for pinging. This PR has been open for a while and was out of sync. I've resolved the conflicts and simplified the changes. Would you mind giving it a review when you have time?

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this repo isn't really actively maintained - and I don't know it any better than anybody else. But this is a small and straightforward change, so I think it can merge with a few small tweaks.

@tgross35
Copy link
Contributor

Bumping MSRV in #172 so that part passes

@unixzii
Copy link
Contributor Author

unixzii commented Aug 11, 2025

Bumping MSRV in #172 so that part passes

Great, so let's use the new syntax then.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Post any benchmarks if you happen to have them (just curious if the effect is actually noticeable - the change is good either way)

@tgross35 tgross35 enabled auto-merge (squash) August 11, 2025 09:27
@tgross35 tgross35 merged commit bfcd9a4 into rust-lang:master Aug 11, 2025
17 checks passed
@unixzii
Copy link
Contributor Author

unixzii commented Aug 11, 2025

Thank you!

Post any benchmarks if you happen to have them (just curious if the effect is actually noticeable - the change is good either way)

Sure, I ran a simple benchmark with the following code:

#[bench]
fn bench_long_pattern(b: &mut rust_test::Bencher) {
    b.iter(|| {
        glob("/*/some_very_very_long_path").unwrap().next();
    })
}

The result shows there is roughly an 8.8% speedup. In addition, the variance dropped significantly, indicating much more consistent performance (malloc does have unpredictable overhead I guess).

before:

test test::bench_long_pattern ... bench:  23,131,008.40 ns/iter (+/- 8,300,816.31)

after:

test test::bench_long_pattern ... bench:  21,097,649.90 ns/iter (+/- 2,002,235.87)

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.

2 participants