Limit base-class initialization checks to development and TESTING modes

We have a number of base-classes that are only intended to be extended, but never to be used directly. To help enforce this during development these base-class constructors will check for direct usage, however that code is obviously not needed in the actual builds.

*Note:* This patch reduces the size of the `gulp mozcentral` output by `~2.7` kilo-bytes, which isn't a lot but still cannot hurt.
This commit is contained in:
Jonas Jenwald 2024-08-12 11:59:13 +02:00
parent aa2337f934
commit aebb8534f3
16 changed files with 79 additions and 20 deletions

View file

@ -23,7 +23,10 @@ import { RefSet, RefSetCache } from "./primitives.js";
class BaseLocalCache {
constructor(options) {
if (this.constructor === BaseLocalCache) {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
this.constructor === BaseLocalCache
) {
unreachable("Cannot initialize BaseLocalCache.");
}
this._onlyRefs = options?.onlyRefs === true;