Skip to content

Commit 19b1070

Browse files
committed
Faster equality compare
1 parent ffa754b commit 19b1070

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/core/src/panic/location.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ pub struct Location<'a> {
4949
#[stable(feature = "panic_hooks", since = "1.10.0")]
5050
impl PartialEq for Location<'_> {
5151
fn eq(&self, other: &Self) -> bool {
52-
self.file() == other.file() && self.line == other.line && self.col == other.col
52+
// Compare col / line first as they're cheaper to compare and more likely to differ,
53+
// while not impacting the result.
54+
self.col == other.col && self.line == other.line && self.file() == other.file()
5355
}
5456
}
5557

0 commit comments

Comments
 (0)