aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/lru_cache/lib.rs7
-rw-r--r--components/style/context.rs2
-rw-r--r--components/style/sharing/mod.rs2
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<T> {
next: u16,
}
-impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
- /// Create an empty LRU cache.
- pub fn new() -> Self {
+impl<T, A: Array<Item=Entry<T>>> Default for LRUCache<T, A> {
+ fn default() -> Self {
let cache = LRUCache {
entries: ArrayVec::new(),
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");
cache
}
+}
+impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
/// 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<E: TElement> SelectorFlagsMap<E> {
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<Candidate> {
impl<Candidate> Default for SharingCacheBase<Candidate> {
fn default() -> Self {
Self {
- entries: LRUCache::new(),
+ entries: LRUCache::default(),
}
}
}