Commit 9dd2903
authored
perf: improve call to
`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()
}
```Path::ends_with (#199)1 parent 94efa90 commit 9dd2903
1 file changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
745 | | - | |
746 | | - | |
747 | | - | |
| 745 | + | |
748 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
| |||
0 commit comments