1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Remove the isNum helper function

The call-sites are replaced by direct `typeof`-checks instead, which removes unnecessary function calls. Note that in the `src/`-folder we already had more `typeof`-cases than `isNum`-calls.

These changes were *mostly* done using regular expression search-and-replace, with two exceptions:
 - In `Font._charToGlyph` we no longer unconditionally update the `width`, since that seems completely unnecessary.
 - In `PDFDocument.documentInfo`, when parsing custom entries, we now do the `typeof`-check once.
This commit is contained in:
Jonas Jenwald 2022-02-22 11:55:34 +01:00
parent edd024c9e7
commit 05edd91bdb
10 changed files with 30 additions and 51 deletions

View file

@ -18,7 +18,6 @@ import {
bytesToString,
FormatError,
info,
isNum,
StreamType,
warn,
} from "../shared/util.js";
@ -1393,7 +1392,7 @@ class Linearization {
Number.isInteger(obj2) &&
isCmd(obj3, "obj") &&
linDict instanceof Dict &&
isNum((obj = linDict.get("Linearized"))) &&
typeof (obj = linDict.get("Linearized")) === "number" &&
obj > 0
)
) {