From 13a3cf27a8ed3ef486a5759bf2afb7b6a32b1626 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 20 Sep 2017 19:00:15 -0700 Subject: [PATCH] LRUCache::new -> LRUCache::default. MozReview-Commit-ID: KouOaYTluRx --- components/lru_cache/lib.rs | 7 ++++--- components/style/context.rs | 2 +- components/style/sharing/mod.rs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/lru_cache/lib.rs b/components/lru_cache/lib.rs index ffffca9a579..ada1ad3a950 100644 --- a/components/lru_cache/lib.rs +++ b/components/lru_cache/lib.rs @@ -33,9 +33,8 @@ pub struct Entry { next: u16, } -impl>> LRUCache { - /// Create an empty LRU cache. - pub fn new() -> Self { +impl>> Default for LRUCache { + fn default() -> Self { let cache = LRUCache { entries: ArrayVec::new(), head: 0, @@ -44,7 +43,9 @@ impl>> LRUCache { assert!(cache.entries.capacity() < u16::max_value() as usize, "Capacity overflow"); cache } +} +impl>> LRUCache { /// Returns the number of elements in the cache. pub fn num_entries(&self) -> usize { self.entries.len() diff --git a/components/style/context.rs b/components/style/context.rs index 390ac09a5c4..8b26754e0cb 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -546,7 +546,7 @@ impl SelectorFlagsMap { pub fn new() -> Self { SelectorFlagsMap { map: FnvHashMap::default(), - cache: LRUCache::new(), + cache: LRUCache::default(), } } diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index 0c652265c0e..e6dabc7f153 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -415,7 +415,7 @@ struct SharingCacheBase { impl Default for SharingCacheBase { fn default() -> Self { Self { - entries: LRUCache::new(), + entries: LRUCache::default(), } } }