Skip to content

Commit 8da03d9

Browse files
author
Cameron Zwarich
committed
Library changes for RFC #43
1 parent 5ebf481 commit 8da03d9

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/libcollections/treemap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,8 @@ fn remove<K: Ord, V>(node: &mut Option<Box<TreeNode<K, V>>>,
15641564
save.level -= 1;
15651565

15661566
if right_level > save.level {
1567-
for x in save.right.mut_iter() { x.level = save.level }
1567+
let save_level = save.level;
1568+
for x in save.right.mut_iter() { x.level = save_level }
15681569
}
15691570

15701571
skew(save);

src/libcollections/trie.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
783783
*child = External(key, value);
784784
return None;
785785
}
786-
Internal(ref mut x) => {
786+
Internal(box ref mut x) => {
787787
return insert(&mut x.count, &mut x.children[chunk(key, idx)], key, value, idx + 1);
788788
}
789789
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,
799799
match mem::replace(child, Nothing) {
800800
External(stored_key, stored_value) => {
801801
let mut new = box TrieNode::new();
802-
insert(&mut new.count,
803-
&mut new.children[chunk(stored_key, idx)],
804-
stored_key, stored_value, idx + 1);
805-
let ret = insert(&mut new.count, &mut new.children[chunk(key, idx)],
806-
key, value, idx + 1);
802+
803+
let ret = {
804+
let new_interior = &mut *new;
805+
insert(&mut new_interior.count,
806+
&mut new_interior.children[chunk(stored_key, idx)],
807+
stored_key, stored_value, idx + 1);
808+
insert(&mut new_interior.count,
809+
&mut new_interior.children[chunk(key, idx)],
810+
key, value, idx + 1)
811+
};
812+
807813
*child = Internal(new);
808814
return ret;
809815
}
@@ -821,7 +827,7 @@ fn remove<T>(count: &mut uint, child: &mut Child<T>, key: uint,
821827
}
822828
}
823829
External(..) => (None, false),
824-
Internal(ref mut x) => {
830+
Internal(box ref mut x) => {
825831
let ret = remove(&mut x.count, &mut x.children[chunk(key, idx)],
826832
key, idx + 1);
827833
(ret, x.count == 0)

src/libstd/collections/lru_cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ impl<K, V> Drop for LruCache<K, V> {
331331
unsafe {
332332
let node: Box<LruEntry<K, V>> = mem::transmute(self.head);
333333
// Prevent compiler from trying to drop the un-initialized field in the sigil node.
334-
let box LruEntry { key: k, value: v, .. } = node;
334+
let box internal_node = node;
335+
let LruEntry { next: _, prev: _, key: k, value: v } = internal_node;
335336
mem::forget(k);
336337
mem::forget(v);
337338
}

0 commit comments

Comments
 (0)