From 521f4dc554d926a56fe588a5683ff5d7cb81b5e1 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 3 May 2026 12:48:38 +0200 Subject: [PATCH] Remove the `CompilerOutput.prototype.finalData` getter (PR 21053 follow-up) Return the data as-is from the `CFFCompiler.prototype.compile` method, rather than making a copy of it first. The reason that it was implemented this way in PR 21053 was to avoid keeping a potentially large `ArrayBuffer` alive, see https://github.com/mozilla/pdf.js/pull/21053#discussion_r3045402988 Having traced all the call-sites in the font-code that directly or indirectly invoke that code, I've now managed to conclude that the compiled CFF-data is never stored on the `Font` instance and using the data as-is thus shouldn't increase permanent memory usage. --- src/core/cff_parser.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index 630c7e3cd..f13bc7706 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -1400,12 +1400,6 @@ class CompilerOutput { return this.#buf.subarray(0, this.#pos); } - get finalData() { - const data = this.#buf.slice(0, this.#pos); - this.#buf = null; - return data; - } - get length() { return this.#pos; } @@ -1534,7 +1528,7 @@ class CFFCompiler { // the sanitizer will bail out. Add a dummy byte to avoid that. output.add([0]); - return output.finalData; + return output.data; } encodeNumber(value) {