Skip to content

Commit f1e78c6

Browse files
committed
Merge pull request #4672 from alexcrichton/linearmap-len-fix
Fix the len() method on LinearMap during popping
2 parents bb51a84 + 810eeef commit f1e78c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libcore/hashmap.rs

+4-1
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
}

0 commit comments

Comments
 (0)