Skip to content

Commit 53d71c1

Browse files
committed
optimize Eq implementation for paths
Filesystems generally have a tree-ish structure which means paths are more likely to share a prefix than a suffix. Absolute paths are especially prone to share long prefixes.
1 parent 47d3875 commit 53d71c1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ impl FusedIterator for Components<'_> {}
951951
impl<'a> cmp::PartialEq for Components<'a> {
952952
#[inline]
953953
fn eq(&self, other: &Components<'a>) -> bool {
954-
Iterator::eq(self.clone(), other.clone())
954+
Iterator::eq(self.clone().rev(), other.clone().rev())
955955
}
956956
}
957957

0 commit comments

Comments
 (0)