Skip to content

Commit d9d2a7f

Browse files
committed
fix typo
1 parent df1b082 commit d9d2a7f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/shape_run_cache.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ pub struct ShapeRunKey {
1717
pub struct ShapeRunCache {
1818
age: u64,
1919
cache: HashMap<ShapeRunKey, (u64, Vec<ShapeGlyph>)>,
20-
age_regitries: Vec<HashSet<ShapeRunKey>>,
20+
age_registries: Vec<HashSet<ShapeRunKey>>,
2121
}
2222

2323
impl Default for ShapeRunCache {
2424
fn default() -> Self {
2525
Self {
2626
age: 0,
2727
cache: Default::default(),
28-
age_regitries: vec![HashSet::default()],
28+
age_registries: vec![HashSet::default()],
2929
}
3030
}
3131
}
@@ -37,12 +37,12 @@ impl ShapeRunCache {
3737
if *age != self.age {
3838
// remove the key from the old age registry
3939
let index = (self.age - *age) as usize;
40-
self.age_regitries[index].remove(key);
40+
self.age_registries[index].remove(key);
4141

4242
// update age
4343
*age = self.age;
4444
// register the key to the new age registry
45-
if let Some(keys) = self.age_regitries.first_mut() {
45+
if let Some(keys) = self.age_registries.first_mut() {
4646
keys.insert(key.clone());
4747
}
4848
}
@@ -52,7 +52,7 @@ impl ShapeRunCache {
5252

5353
/// Insert cache item with current age
5454
pub fn insert(&mut self, key: ShapeRunKey, glyphs: Vec<ShapeGlyph>) {
55-
if let Some(keys) = self.age_regitries.first_mut() {
55+
if let Some(keys) = self.age_registries.first_mut() {
5656
// register the key to the current age
5757
keys.insert(key.clone());
5858
}
@@ -63,8 +63,8 @@ impl ShapeRunCache {
6363
pub fn trim(&mut self, keep_ages: u64) {
6464
// remove the age registries that's greater than kept ages
6565
// and remove the keys from cache saved in the registries
66-
while self.age_regitries.len() as u64 > keep_ages {
67-
if let Some(keys) = self.age_regitries.pop() {
66+
while self.age_registries.len() as u64 > keep_ages {
67+
if let Some(keys) = self.age_registries.pop() {
6868
for key in keys {
6969
self.cache.remove(&key);
7070
}
@@ -74,7 +74,7 @@ impl ShapeRunCache {
7474
self.age += 1;
7575
// insert a new registry to the front of the Vec
7676
// to keep keys for the current age
77-
self.age_regitries.insert(0, HashSet::default());
77+
self.age_registries.insert(0, HashSet::default());
7878
}
7979
}
8080

@@ -124,30 +124,30 @@ mod test {
124124
cache.trim(1);
125125
// all was just inserted so all kept
126126
assert_eq!(cache.cache.len(), 3);
127-
assert_eq!(cache.age_regitries.len(), 2);
127+
assert_eq!(cache.age_registries.len(), 2);
128128

129129
cache.get(&key1);
130130
cache.get(&key2);
131131
cache.trim(1);
132132
// only key1 and key2 was refreshed, so key3 was trimed
133133
assert_eq!(cache.cache.len(), 2);
134-
assert_eq!(cache.age_regitries.len(), 2);
134+
assert_eq!(cache.age_registries.len(), 2);
135135

136136
cache.get(&key1);
137137
cache.trim(1);
138138
// only key1 was refreshed, so key2 was trimed
139139
assert_eq!(cache.cache.len(), 1);
140-
assert_eq!(cache.age_regitries.len(), 2);
140+
assert_eq!(cache.age_registries.len(), 2);
141141

142142
cache.trim(2);
143143
// keep 2 ages, so even key1 wasn't refreshed,
144144
// it was still kept
145145
assert_eq!(cache.cache.len(), 1);
146-
assert_eq!(cache.age_regitries.len(), 3);
146+
assert_eq!(cache.age_registries.len(), 3);
147147

148148
cache.trim(2);
149149
// key1 is now too old for 2 ages, so it was trimed
150150
assert_eq!(cache.cache.len(), 0);
151-
assert_eq!(cache.age_regitries.len(), 3);
151+
assert_eq!(cache.age_registries.len(), 3);
152152
}
153153
}

0 commit comments

Comments
 (0)