Fix the len() method on LinearMap during popping

This commit is contained in:
Alex Crichton 2013-01-29 11:16:39 -05:00
parent fc9650b146
commit 810eeef444
1 changed files with 4 additions and 1 deletions

View File

@ -220,6 +220,9 @@ pub mod linear {
}, },
}; };
/* re-inserting buckets may cause changes in size, so remember what
our new size is ahead of time before we start insertions */
let size = self.size - 1;
idx = self.next_bucket(idx, len_buckets); idx = self.next_bucket(idx, len_buckets);
while self.buckets[idx].is_some() { while self.buckets[idx].is_some() {
let mut bucket = None; let mut bucket = None;
@ -227,7 +230,7 @@ pub mod linear {
self.insert_opt_bucket(bucket); self.insert_opt_bucket(bucket);
idx = self.next_bucket(idx, len_buckets); idx = self.next_bucket(idx, len_buckets);
} }
self.size -= 1; self.size = size;
value value
} }