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

Add an abstract base-class, which all the various Stream implementations inherit from

By having an abstract base-class, it becomes a lot clearer exactly which methods/getters are expected to exist on all Stream instances.
Furthermore, since a number of the methods are *identical* for all Stream implementations, this reduces unnecessary code duplication in the `Stream`, `DecodeStream`, and `ChunkedStream` classes.

For e.g. `gulp mozcentral`, the *built* `pdf.worker.js` files decreases from `1 619 329` to `1 616 115` bytes with this patch-series.
This commit is contained in:
Jonas Jenwald 2021-04-27 17:08:54 +02:00
parent 6151b4ecac
commit 67415bfabe
6 changed files with 138 additions and 158 deletions

View file

@ -14,6 +14,7 @@
*/
import { assert, unreachable } from "../shared/util.js";
import { BaseStream } from "./base_stream.js";
const EOF = {};
@ -383,7 +384,7 @@ function isRefsEqual(v1, v2) {
}
function isStream(v) {
return typeof v === "object" && v !== null && v.getBytes !== undefined;
return v instanceof BaseStream;
}
function clearPrimitiveCaches() {