diff --git a/src/libcollections/lru_cache.rs b/src/libcollections/lru_cache.rs index 84553782104..ef49ada322a 100644 --- a/src/libcollections/lru_cache.rs +++ b/src/libcollections/lru_cache.rs @@ -59,7 +59,6 @@ pub struct LruCache { map: HashMap, ~LruEntry>, max_size: uint, head: *mut LruEntry, - tail: *mut LruEntry, } impl> Hash for KeyRef { @@ -103,11 +102,10 @@ impl LruCache { map: HashMap::new(), max_size: capacity, head: unsafe{ cast::transmute(~LruEntry::::new()) }, - tail: unsafe{ cast::transmute(~LruEntry::::new()) }, }; unsafe { - (*cache.head).next = cache.tail; - (*cache.tail).prev = cache.head; + (*cache.head).next = cache.head; + (*cache.head).prev = cache.head; } return cache; } @@ -191,7 +189,7 @@ impl LruCache { #[inline] fn remove_lru(&mut self) { if self.len() > 0 { - let lru = unsafe { (*self.tail).prev }; + let lru = unsafe { (*self.head).prev }; self.detach(lru); unsafe { match (*lru).key { @@ -269,7 +267,6 @@ impl Drop for LruCache { fn drop(&mut self) { unsafe { let _: ~LruEntry = cast::transmute(self.head); - let _: ~LruEntry = cast::transmute(self.tail); } } }