Skip to content

Commit e2f88e4

Browse files
committed
Hashmap fix?
1 parent 8c01e34 commit e2f88e4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libcore/hashmap.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,17 @@ pub mod linear {
220220
},
221221
};
222222

223+
/* re-inserting buckets may cause changes in size, so remember what
224+
our new size is ahead of time before we start insertions */
225+
let size = self.size - 1;
223226
idx = self.next_bucket(idx, len_buckets);
224227
while self.buckets[idx].is_some() {
225228
let mut bucket = None;
226229
bucket <-> self.buckets[idx];
227230
self.insert_opt_bucket(bucket);
228231
idx = self.next_bucket(idx, len_buckets);
229232
}
230-
self.size -= 1;
233+
self.size = size;
231234

232235
value
233236
}
@@ -428,7 +431,6 @@ pub mod linear {
428431
impl <T: Hash IterBytes Eq> LinearSet<T>: Container {
429432
/// Return the number of elements in the set
430433
pure fn len(&self) -> uint { self.map.len() }
431-
432434
/// Return true if the set contains no elements
433435
pure fn is_empty(&self) -> bool { self.map.is_empty() }
434436
}

0 commit comments

Comments
 (0)