From 42566f40fb6b76cc2ecc9aa9d9e71d9fc40d57f2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 26 Mar 2026 16:46:01 +0100 Subject: [PATCH] Reduce allocations in the `FontInfo.prototype.#readString` method (PR 20197 follow-up) Looking at the very similar `CssFontInfo.prototype.#readString` and `SystemFontInfo.prototype.#readString` methods they decode using the data as-is, but the `FontInfo.prototype.#readString` method for some reason copies the data into a new `Uint8Array` first; fixes yet another bug/inefficiency in PR 20197. --- src/display/obj_bin_transform_display.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/display/obj_bin_transform_display.js b/src/display/obj_bin_transform_display.js index 1297a88ad..465cdc9d3 100644 --- a/src/display/obj_bin_transform_display.js +++ b/src/display/obj_bin_transform_display.js @@ -247,9 +247,9 @@ class FontInfo { offset += this.#view.getUint32(offset) + 4; } const length = this.#view.getUint32(offset); - const stringData = new Uint8Array(length); - stringData.set(new Uint8Array(this.#buffer, offset + 4, length)); - return this.#decoder.decode(stringData); + return this.#decoder.decode( + new Uint8Array(this.#buffer, offset + 4, length) + ); } get fallbackName() {