LRUCache::new -> LRUCache::default.

MozReview-Commit-ID: KouOaYTluRx
This commit is contained in:
Bobby Holley 2017-09-20 19:00:15 -07:00
parent 8b6c5988b5
commit 13a3cf27a8
3 changed files with 6 additions and 5 deletions

View file

@ -33,9 +33,8 @@ pub struct Entry<T> {
next: u16, next: u16,
} }
impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> { impl<T, A: Array<Item=Entry<T>>> Default for LRUCache<T, A> {
/// Create an empty LRU cache. fn default() -> Self {
pub fn new() -> Self {
let cache = LRUCache { let cache = LRUCache {
entries: ArrayVec::new(), entries: ArrayVec::new(),
head: 0, head: 0,
@ -44,7 +43,9 @@ impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
assert!(cache.entries.capacity() < u16::max_value() as usize, "Capacity overflow"); assert!(cache.entries.capacity() < u16::max_value() as usize, "Capacity overflow");
cache cache
} }
}
impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
/// Returns the number of elements in the cache. /// Returns the number of elements in the cache.
pub fn num_entries(&self) -> usize { pub fn num_entries(&self) -> usize {
self.entries.len() self.entries.len()

View file

@ -546,7 +546,7 @@ impl<E: TElement> SelectorFlagsMap<E> {
pub fn new() -> Self { pub fn new() -> Self {
SelectorFlagsMap { SelectorFlagsMap {
map: FnvHashMap::default(), map: FnvHashMap::default(),
cache: LRUCache::new(), cache: LRUCache::default(),
} }
} }

View file

@ -415,7 +415,7 @@ struct SharingCacheBase<Candidate> {
impl<Candidate> Default for SharingCacheBase<Candidate> { impl<Candidate> Default for SharingCacheBase<Candidate> {
fn default() -> Self { fn default() -> Self {
Self { Self {
entries: LRUCache::new(), entries: LRUCache::default(),
} }
} }
} }