Optimize memory allocations#147
Conversation
|
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? |
tgross35
left a comment
There was a problem hiding this comment.
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.
|
Bumping MSRV in #172 so that part passes |
Great, so let's use the new syntax then. |
tgross35
left a comment
There was a problem hiding this comment.
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: after: |
Remove the redundant pattern joining, which can reduce memory allocations during the iteration.