1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Remove the isEOF helper function and slightly re-factor EOF

Given how trivial the `isEOF` function is, we can simply inline the check at the various call-sites and remove the function (which ought to be ever so slightly more efficient as well).
Furthermore, this patch also changes the `EOF` primitive itself to a `Symbol` instead of an Object since that has the nice benefit of making it unclonable (thus preventing *accidentally* trying to send `EOF` from the worker-thread).
This commit is contained in:
Jonas Jenwald 2021-08-03 12:41:58 +02:00
parent 0b95d698d8
commit 766299016f
4 changed files with 16 additions and 35 deletions

View file

@ -16,7 +16,7 @@
import { assert, shadow, unreachable } from "../shared/util.js";
import { BaseStream } from "./base_stream.js";
const EOF = {};
const EOF = Symbol("EOF");
const Name = (function NameClosure() {
let nameCache = Object.create(null);
@ -338,10 +338,6 @@ class RefSetCache {
}
}
function isEOF(v) {
return v === EOF;
}
function isName(v, name) {
return v instanceof Name && (name === undefined || v.name === name);
}
@ -390,7 +386,6 @@ export {
EOF,
isCmd,
isDict,
isEOF,
isName,
isRef,
isRefsEqual,