diff options
| author | Cameron Zwarich <zwarich@mozilla.com> | 2014-07-30 13:36:21 -0700 |
|---|---|---|
| committer | Cameron Zwarich <zwarich@mozilla.com> | 2014-07-30 13:36:21 -0700 |
| commit | 8da03d9771bc827eae713d16bca7bec4c5fe6a10 (patch) | |
| tree | ba194b28561175e8d3614ce76bd74e24cbb87f82 | |
| parent | 5ebf4813a6503d5312f457b8a6ba7b6998a45f2b (diff) | |
| download | rust-8da03d9771bc827eae713d16bca7bec4c5fe6a10.tar.gz rust-8da03d9771bc827eae713d16bca7bec4c5fe6a10.zip | |
Library changes for RFC #43
| -rw-r--r-- | src/libcollections/treemap.rs | 3 | ||||
| -rw-r--r-- | src/libcollections/trie.rs | 20 | ||||
| -rw-r--r-- | src/libstd/collections/lru_cache.rs | 3 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index 5de23b42f5c..6a29a9a75b8 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -1564,7 +1564,8 @@ fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>, save.level -= 1; if right_level > save.level { - for x in save.right.mut_iter() { x.level = save.level } + let save_level = save.level; + for x in save.right.mut_iter() { x.level = save_level } } skew(save); diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index cd011b0e013..ec7ed919177 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -783,7 +783,7 @@ fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T, *child = External(key, value); return None; } - Internal(ref mut x) => { + Internal(box ref mut x) => { return insert(&mut x.count, &mut x.children[chunk(key, idx)], key, value, idx + 1); } External(stored_key, ref mut stored_value) if stored_key == key => { @@ -799,11 +799,17 @@ fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T, match mem::replace(child, Nothing) { External(stored_key, stored_value) => { let mut new = box TrieNode::new(); - insert(&mut new.count, - &mut new.children[chunk(stored_key, idx)], - stored_key, stored_value, idx + 1); - let ret = insert(&mut new.count, &mut new.children[chunk(key, idx)], - key, value, idx + 1); + + let ret = { + let new_interior = &mut *new; + insert(&mut new_interior.count, + &mut new_interior.children[chunk(stored_key, idx)], + stored_key, stored_value, idx + 1); + insert(&mut new_interior.count, + &mut new_interior.children[chunk(key, idx)], + key, value, idx + 1) + }; + *child = Internal(new); return ret; } @@ -821,7 +827,7 @@ fn remove<T>(count: &mut uint, child: &mut Child<T>, key: uint, } } External(..) => (None, false), - Internal(ref mut x) => { + Internal(box ref mut x) => { let ret = remove(&mut x.count, &mut x.children[chunk(key, idx)], key, idx + 1); (ret, x.count == 0) diff --git a/src/libstd/collections/lru_cache.rs b/src/libstd/collections/lru_cache.rs index 45e971a675f..32a16053fff 100644 --- a/src/libstd/collections/lru_cache.rs +++ b/src/libstd/collections/lru_cache.rs @@ -331,7 +331,8 @@ impl<K, V> Drop for LruCache<K, V> { unsafe { let node: Box<LruEntry<K, V>> = mem::transmute(self.head); // Prevent compiler from trying to drop the un-initialized field in the sigil node. - let box LruEntry { key: k, value: v, .. } = node; + let box internal_node = node; + let LruEntry { next: _, prev: _, key: k, value: v } = internal_node; mem::forget(k); mem::forget(v); } |
