Skip to content

Commit 0f71be4

Browse files
zachs18cuviper
authored andcommitted
In BTreeMap::eq, do not compare the elements if the sizes are different.
Reverts 68a7c25 in library/ (cherry picked from commit 4adcdbb)
1 parent 4bd154f commit 0f71be4

File tree

1 file changed

+1
-1
lines changed
  • library/alloc/src/collections/btree

1 file changed

+1
-1
lines changed

library/alloc/src/collections/btree/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,7 @@ impl<K, V> Default for BTreeMap<K, V> {
24142414
#[stable(feature = "rust1", since = "1.0.0")]
24152415
impl<K: PartialEq, V: PartialEq, A: Allocator + Clone> PartialEq for BTreeMap<K, V, A> {
24162416
fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
2417-
self.iter().eq(other)
2417+
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
24182418
}
24192419
}
24202420

0 commit comments

Comments
 (0)