Skip to content

Commit

Permalink
cache: Attempt first steps at finding out more about #1
Browse files Browse the repository at this point in the history
  • Loading branch information
dermesser committed Feb 16, 2020
1 parent a145fe2 commit b2ce253
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ impl<T> LRUList<T> {
}

fn remove_last(&mut self) -> Option<T> {
if self.count() == 0 {
return None
}
if self.head.prev.is_some() {
let mut lasto = unsafe {
replace(
Expand All @@ -74,7 +77,10 @@ impl<T> LRUList<T> {
)
};

assert!(lasto.is_some());
if let Some(ref mut last) = lasto {
assert!(last.prev.is_some());
assert!(self.head.prev.is_some());
self.head.prev = last.prev;
self.count -= 1;
return replace(&mut (*last).data, None);
Expand Down

0 comments on commit b2ce253

Please sign in to comment.