From c121def80696c9e4786af645fe1b45269412a94d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 25 Jun 2014 20:56:43 +0200 Subject: [PATCH] A few small optimizations for CIDFontType2 fonts Cache a constant length and replace one usage of |in| with a comparison against undefined. --- src/core/fonts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index f86272e4f..64f680ed7 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -3888,8 +3888,9 @@ var Font = (function FontClosure() { } var charCodeToGlyphId = [], charCode; - if (properties.type == 'CIDFontType2') { + if (properties.type === 'CIDFontType2') { var cidToGidMap = properties.cidToGidMap || []; + var cidToGidMapLength = cidToGidMap.length; var cMap = properties.cMap.map; for (charCode in cMap) { charCode |= 0; @@ -3897,9 +3898,9 @@ var Font = (function FontClosure() { assert(cid.length === 1, 'Max size of CID is 65,535'); cid = cid.charCodeAt(0); var glyphId = -1; - if (cidToGidMap.length === 0) { + if (cidToGidMapLength === 0) { glyphId = charCode; - } else if (cid in cidToGidMap) { + } else if (cidToGidMap[cid] !== undefined) { glyphId = cidToGidMap[cid]; } if (glyphId >= 0 && glyphId < numGlyphs) {