Skip to content

Commit 42566f4

Browse files
committed
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.
1 parent 601d961 commit 42566f4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/display/obj_bin_transform_display.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ class FontInfo {
247247
offset += this.#view.getUint32(offset) + 4;
248248
}
249249
const length = this.#view.getUint32(offset);
250-
const stringData = new Uint8Array(length);
251-
stringData.set(new Uint8Array(this.#buffer, offset + 4, length));
252-
return this.#decoder.decode(stringData);
250+
return this.#decoder.decode(
251+
new Uint8Array(this.#buffer, offset + 4, length)
252+
);
253253
}
254254

255255
get fallbackName() {

0 commit comments

Comments
 (0)