Don't unlink node when updating inBitmap and verify undefined

This commit is contained in:
Daniel Imms
2018-09-17 07:52:37 -07:00
parent d9ec47ab7a
commit cbe7b21090
2 changed files with 16 additions and 1 deletions
+5 -1
View File
@@ -335,7 +335,11 @@ export default class DynamicCharAtlas extends BaseCharAtlas {
// Mark all new glyphs as in bitmap
for (let i = 0; i < countAtGeneration; i++) {
const key = this._glyphsWaitingOnBitmapQueue[i];
this._cacheMap.get(key).inBitmap = true;
const value = this._cacheMap.peekValue(key);
// If the value has already been evicted, do nothing
if (value) {
value.inBitmap = true;
}
this._glyphsWaitingOnBitmapQueue[i] = 0;
}
+11
View File
@@ -80,6 +80,17 @@ export default class LRUMap<T> {
return null;
}
/**
* Gets a value from a key without marking it as the most recently used item.
*/
public peekValue(key: number): T | null {
const node = this._map[key];
if (node !== undefined) {
return node.value;
}
return null;
}
public peek(): T | null {
const head = this._head;
return head === null ? null : head.value;