Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset LinearMap.size when expanding buckets #4316

Merged
merged 1 commit into from
Jan 1, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/libcore/send_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub mod linear {
let mut old_buckets = vec::from_fn(new_capacity, |_i| None);
self.buckets <-> old_buckets;

self.size = 0;
for uint::range(0, old_capacity) |i| {
let mut bucket = None;
bucket <-> old_buckets[i];
Expand Down Expand Up @@ -583,4 +584,22 @@ pub mod test {

assert m1 == m2;
}

#[test]
pub fn test_expand() {
let mut m = ~LinearMap();

assert m.len() == 0;
assert m.is_empty();

let mut i = 0u;
let old_resize_at = m.resize_at;
while old_resize_at == m.resize_at {
m.insert(i, i);
i += 1;
}

assert m.len() == i;
assert !m.is_empty();
}
}