From cbe7b21090b7744b5ab3116b20db0bd12215c8d3 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 17 Sep 2018 07:52:37 -0700 Subject: [PATCH] Don't unlink node when updating inBitmap and verify undefined --- src/renderer/atlas/DynamicCharAtlas.ts | 6 +++++- src/renderer/atlas/LRUMap.ts | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/renderer/atlas/DynamicCharAtlas.ts b/src/renderer/atlas/DynamicCharAtlas.ts index 31deff55e..04d28c876 100644 --- a/src/renderer/atlas/DynamicCharAtlas.ts +++ b/src/renderer/atlas/DynamicCharAtlas.ts @@ -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; } diff --git a/src/renderer/atlas/LRUMap.ts b/src/renderer/atlas/LRUMap.ts index 984dbb724..d7e01ec6c 100644 --- a/src/renderer/atlas/LRUMap.ts +++ b/src/renderer/atlas/LRUMap.ts @@ -80,6 +80,17 @@ export default class LRUMap { 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;