mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-10 23:34:02 +02:00
Replace a couple of loops with TypedArray.prototype.fill() in the src/core/ascii_85_stream.js file
This commit is contained in:
parent
dd8f0a327f
commit
dc448b3ceb
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user