about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-01-29 10:38:41 -0800
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-01-29 10:38:41 -0800
commitf1e78c6dd7dc41a9937c466a7af5d0efc779909f (patch)
tree22a0a48d2fb8fa94a200e68b0cc47a6218ef9da2 /src
parentbb51a8442fb16d71faccac1abfa953d8b1e37cb7 (diff)
parent810eeef444d0f0b56d6fdc44dbfa10e7f155bd0a (diff)
downloadrust-f1e78c6dd7dc41a9937c466a7af5d0efc779909f.tar.gz
rust-f1e78c6dd7dc41a9937c466a7af5d0efc779909f.zip
Merge pull request #4672 from alexcrichton/linearmap-len-fix
Fix the len() method on LinearMap during popping
Diffstat (limited to 'src')
-rw-r--r--src/libcore/hashmap.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs
index 47f0fcfd381..27b5ddadff9 100644
--- a/src/libcore/hashmap.rs
+++ b/src/libcore/hashmap.rs
@@ -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);
             while self.buckets[idx].is_some() {
                 let mut bucket = None;
@@ -227,7 +230,7 @@ pub mod linear {
                 self.insert_opt_bucket(bucket);
                 idx = self.next_bucket(idx, len_buckets);
             }
-            self.size -= 1;
+            self.size = size;
 
             value
         }