From 7de5e6c487c2b3b803c619f8c19ffa8742535e49 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 22 Jan 2013 21:13:06 -0500 Subject: [PATCH] migrate gc.rs to LinearSet --- src/libcore/gc.rs | 14 ++++---------- src/libcore/send_map.rs | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index 886f2d1c0831..b98c79f8d0e7 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -44,7 +44,7 @@ use io; use libc::{size_t, uintptr_t}; use option::{None, Option, Some}; use ptr; -use send_map::linear::LinearMap; +use send_map::linear::LinearSet; use stackwalk; use sys; @@ -294,12 +294,6 @@ pub fn gc() { } } -type RootSet = LinearMap<*Word,()>; - -fn RootSet() -> RootSet { - LinearMap() -} - #[cfg(gc)] fn expect_sentinel() -> bool { true } @@ -337,13 +331,13 @@ pub fn cleanup_stack_for_failure() { ptr::null() }; - let mut roots = ~RootSet(); + let mut roots = LinearSet::new(); for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| { // Track roots to avoid double frees. - if roots.find(&*root).is_some() { + if roots.contains(&*root) { loop; } - roots.insert(*root, ()); + roots.insert(*root); if ptr::is_null(tydesc) { // FIXME #4420: Destroy this box diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index dc4e24c4f8a3..788c4fdbd5e4 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -485,7 +485,7 @@ pub mod linear { fn remove(&mut self, value: &T) -> bool { self.map.remove(value) } } - impl LinearSet { + pub impl LinearSet { /// Create an empty LinearSet static fn new() -> LinearSet { LinearSet{map: LinearMap()} } }