BlogDocs

perf: improve call to `Path::ends_with`(#199)

Merged
Merging
perf-ends-with
(
1e02488
) into
main
(
94efa90
)
0%
IMPROVEMENTS
0
REGRESSIONS
0
UNTOUCHED
2
NEW
0
DROPPED
0
IGNORED
0

Benchmarks

Passed

resolver[single-thread]
benches/resolver.rs::resolver::bench_resolver::resolver[single-thread]
+1%
460.9 µs
455.7 µs
resolver[multi-thread]
benches/resolver.rs::resolver::bench_resolver::resolver[multi-thread]
-2%
484.2 µs
491.8 µs

Commits

Click on a commit to change the comparison range
base
main
94efa90
0%
perf: improve call to `Path::ends_with` `Path::ends_with` converts the comparator to a `Path` and compares all components. `module_name` in `cached_path.path().ends_with(module_name)` is guaranteed to be a single component so this overhead can be avoided. ```rust #[must_use] pub fn ends_with<P: AsRef<Path>>(&self, child: P) -> bool { self._ends_with(child.as_ref()) } fn _ends_with(&self, child: &Path) -> bool { iter_after(self.components().rev(), child.components().rev()).is_some() } ```
1e02488
3 months ago
by Boshen
ResourcesHomePricingDocsBlogGitHubChangelog
Copyright © 2024 CodSpeed Technology SAS. All rights reserved.