Fix an awful bug in LRUCache::touch().

MozReview-Commit-ID: 3l7L0MfdOxh
This commit is contained in:
Bobby Holley 2017-09-11 16:12:32 -07:00
parent db67cd1759
commit c409c2089c

View file

@ -39,8 +39,7 @@ impl<K: Array> LRUCache<K> {
#[inline]
/// Touch a given entry, putting it first in the list.
pub fn touch(&mut self, pos: usize) {
let last_index = self.entries.len() - 1;
if pos != last_index {
if pos != 0 {
let entry = self.entries.remove(pos).unwrap();
self.entries.push_front(entry);
}