mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Prefer instanceof Cmd
rather than calling isCmd()
with *one* argument
Unless you actually need to check that something is both a `Cmd` and also of the *correct* type, using `instanceof Cmd` 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 `isCmd` helper function for where it makes sense.
This commit is contained in:
parent
3635a9a333
commit
67b658e8d5
3 changed files with 10 additions and 2 deletions
|
@ -20,7 +20,7 @@ import {
|
|||
unreachable,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { EOF, isCmd, isName } from "./primitives.js";
|
||||
import { Cmd, EOF, isCmd, isName } from "./primitives.js";
|
||||
import { BaseStream } from "./base_stream.js";
|
||||
import { Lexer } from "./parser.js";
|
||||
import { MissingDataException } from "./core_utils.js";
|
||||
|
@ -920,7 +920,7 @@ const CMapFactory = (function CMapFactoryClosure() {
|
|||
parseCMapName(cMap, lexer);
|
||||
}
|
||||
previous = obj;
|
||||
} else if (isCmd(obj)) {
|
||||
} else if (obj instanceof Cmd) {
|
||||
switch (obj.cmd) {
|
||||
case "endcmap":
|
||||
break objLoop;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue