@@ -59,7 +59,6 @@ pub struct LruCache<K, V> {
59
59
map : HashMap < KeyRef < K > , ~LruEntry < K , V > > ,
60
60
max_size : uint ,
61
61
head : * mut LruEntry < K , V > ,
62
- tail : * mut LruEntry < K , V > ,
63
62
}
64
63
65
64
impl < S , K : Hash < S > > Hash < S > for KeyRef < K > {
@@ -103,11 +102,10 @@ impl<K: Hash + TotalEq, V> LruCache<K, V> {
103
102
map : HashMap :: new ( ) ,
104
103
max_size : capacity,
105
104
head : unsafe { cast:: transmute ( ~LruEntry :: < K , V > :: new ( ) ) } ,
106
- tail : unsafe { cast:: transmute ( ~LruEntry :: < K , V > :: new ( ) ) } ,
107
105
} ;
108
106
unsafe {
109
- ( * cache. head ) . next = cache. tail ;
110
- ( * cache. tail ) . prev = cache. head ;
107
+ ( * cache. head ) . next = cache. head ;
108
+ ( * cache. head ) . prev = cache. head ;
111
109
}
112
110
return cache;
113
111
}
@@ -191,7 +189,7 @@ impl<K: Hash + TotalEq, V> LruCache<K, V> {
191
189
#[ inline]
192
190
fn remove_lru ( & mut self ) {
193
191
if self . len ( ) > 0 {
194
- let lru = unsafe { ( * self . tail ) . prev } ;
192
+ let lru = unsafe { ( * self . head ) . prev } ;
195
193
self . detach ( lru) ;
196
194
unsafe {
197
195
match ( * lru) . key {
@@ -269,7 +267,6 @@ impl<K, V> Drop for LruCache<K, V> {
269
267
fn drop ( & mut self ) {
270
268
unsafe {
271
269
let _: ~LruEntry < K , V > = cast:: transmute ( self . head ) ;
272
- let _: ~LruEntry < K , V > = cast:: transmute ( self . tail ) ;
273
270
}
274
271
}
275
272
}
0 commit comments