In BTreeMap::eq, do not compare the elements if the sizes are different.

Reverts 68a7c25078 in library/

(cherry picked from commit 4adcdbb58b)
This commit is contained in:
Zachary S
2025-11-19 22:49:44 -06:00
committed by Josh Stone
parent 4bd154fa71
commit 0f71be4da5
+1 -1
View File
@@ -2414,7 +2414,7 @@ fn default() -> BTreeMap<K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<K: PartialEq, V: PartialEq, A: Allocator + Clone> PartialEq for BTreeMap<K, V, A> {
fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
self.iter().eq(other)
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
}
}