Skip to content

Commit

Permalink
optimize Eq implementation for paths
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the8472 committed Jun 9, 2021
1 parent 47d3875 commit 53d71c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ impl FusedIterator for Components<'_> {}
impl<'a> cmp::PartialEq for Components<'a> {
#[inline]
fn eq(&self, other: &Components<'a>) -> bool {
Iterator::eq(self.clone(), other.clone())
Iterator::eq(self.clone().rev(), other.clone().rev())
}
}

Expand Down

0 comments on commit 53d71c1

Please sign in to comment.