mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Prefer instanceof Dict
rather than calling isDict()
with one argument
Unless you actually need to check that something is both a `Dict` and also of the *correct* type, using `instanceof Dict` directly should be a tiny bit more efficient since it avoids one function call and an unnecessary `undefined` check. This patch uses ESLint to enforce this, since we obviously still want to keep the `isDict` helper function for where it makes sense.
This commit is contained in:
parent
67b658e8d5
commit
4df82ad31e
18 changed files with 83 additions and 93 deletions
|
@ -44,7 +44,7 @@ import {
|
|||
XRefEntryException,
|
||||
XRefParseException,
|
||||
} from "./core_utils.js";
|
||||
import { Dict, isDict, isName, Name, Ref } from "./primitives.js";
|
||||
import { Dict, isName, Name, Ref } from "./primitives.js";
|
||||
import { getXfaFontDict, getXfaFontName } from "./xfa_fonts.js";
|
||||
import { NullStream, Stream } from "./stream.js";
|
||||
import { AnnotationFactory } from "./annotation.js";
|
||||
|
@ -120,7 +120,7 @@ class Page {
|
|||
if (!Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
if (value.length === 1 || !isDict(value[0])) {
|
||||
if (value.length === 1 || !(value[0] instanceof Dict)) {
|
||||
return value[0];
|
||||
}
|
||||
return Dict.merge({ xref: this.xref, dictArray: value });
|
||||
|
@ -1175,7 +1175,7 @@ class PDFDocument {
|
|||
info("The document information dictionary is invalid.");
|
||||
}
|
||||
|
||||
if (isDict(infoDict)) {
|
||||
if (infoDict instanceof Dict) {
|
||||
// Fill the document info with valid entries from the specification,
|
||||
// as well as any existing well-formed custom entries.
|
||||
for (const key of infoDict.getKeys()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue