From 4521c347757329d4166e1a1c0239de2fcdd508e9 Mon Sep 17 00:00:00 2001 From: Jihyun Yu Date: Tue, 28 May 2013 12:35:06 +0900 Subject: [PATCH] Fix #6696 --- src/libextra/smallintmap.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs index 069368d3fea..a3c02b2366d 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libextra/smallintmap.rs @@ -246,7 +246,14 @@ fn difference(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool { fn symmetric_difference(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool { - self.difference(other, f) && other.difference(self, f) + let len = cmp::max(self.map.v.len() ,other.map.v.len()); + + for uint::range(0, len) |i| { + if self.contains(&i) ^ other.contains(&i) { + if !f(&i) { return false; } + } + } + return true; } /// Visit the values representing the uintersection @@ -256,7 +263,14 @@ fn intersection(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool { /// Visit the values representing the union fn union(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool { - self.each(f) && other.each(|v| self.contains(v) || f(v)) + let len = cmp::max(self.map.v.len() ,other.map.v.len()); + + for uint::range(0, len) |i| { + if self.contains(&i) || other.contains(&i) { + if !f(&i) { return false; } + } + } + return true; } }