From 7190bc23a856b12b06e91d78eb4564e9a0a9a775 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 18 May 2021 09:04:14 +0200 Subject: [PATCH] Remove unnecessary `in` checks of Arrays, when building the `charCodeToGlyphId` for TrueType fonts Note that all standard Encodings have the same length (i.e. `256` elements) and that missing entries are always represented by empty strings, hence why a separate exists-check isn't necessary in the `baseEncoding` case. --- src/core/fonts.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index b391ab693..6fb746197 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2550,12 +2550,9 @@ class Font { const glyphsUnicodeMap = getGlyphsUnicode(); for (let charCode = 0; charCode < 256; charCode++) { let glyphName; - if (this.differences && charCode in this.differences) { + if (this.differences[charCode] !== undefined) { glyphName = this.differences[charCode]; - } else if ( - charCode in baseEncoding && - baseEncoding[charCode] !== "" - ) { + } else if (baseEncoding[charCode] !== "") { glyphName = baseEncoding[charCode]; } else { glyphName = StandardEncoding[charCode];