From dc448b3ceb637d089d5c579dd830cbdc5b1d5833 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 6 Apr 2026 11:44:43 +0200 Subject: [PATCH] Replace a couple of loops with `TypedArray.prototype.fill()` in the `src/core/ascii_85_stream.js` file --- src/core/ascii_85_stream.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/core/ascii_85_stream.js b/src/core/ascii_85_stream.js index 0bbcec999..c3e2182c7 100644 --- a/src/core/ascii_85_stream.js +++ b/src/core/ascii_85_stream.js @@ -17,6 +17,8 @@ import { DecodeStream } from "./decode_stream.js"; import { isWhiteSpace } from "./core_utils.js"; class Ascii85Stream extends DecodeStream { + #input = new Uint8Array(5); + constructor(str, maybeLength) { // Most streams increase in size when decoded, but Ascii85 streams // typically shrink by ~20%. @@ -27,7 +29,6 @@ class Ascii85Stream extends DecodeStream { this.stream = str; this.dict = str.dict; - this.input = new Uint8Array(5); } readBlock() { @@ -53,12 +54,10 @@ class Ascii85Stream extends DecodeStream { // special code for z if (c === Z_LOWER_CHAR) { buffer = this.ensureBuffer(bufferLength + 4); - for (i = 0; i < 4; ++i) { - buffer[bufferLength + i] = 0; - } + buffer.fill(0, bufferLength, bufferLength + 4); this.bufferLength += 4; } else { - const input = this.input; + const input = this.#input; input[0] = c; for (i = 1; i < 5; ++i) { c = str.getByte(); @@ -77,9 +76,7 @@ class Ascii85Stream extends DecodeStream { // partial ending; if (i < 5) { - for (; i < 5; ++i) { - input[i] = 0x21 + 84; - } + input.fill(0x21 + 84, i, 5); this.eof = true; } let t = 0;