mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
LRUCache::new -> LRUCache::default.
MozReview-Commit-ID: KouOaYTluRx
This commit is contained in:
parent
8b6c5988b5
commit
13a3cf27a8
3 changed files with 6 additions and 5 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue