mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-26 18:15:48 +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";
|
import { isWhiteSpace } from "./core_utils.js";
|
||||||
|
|
||||||
class Ascii85Stream extends DecodeStream {
|
class Ascii85Stream extends DecodeStream {
|
||||||
|
#input = new Uint8Array(5);
|
||||||
|
|
||||||
constructor(str, maybeLength) {
|
constructor(str, maybeLength) {
|
||||||
// Most streams increase in size when decoded, but Ascii85 streams
|
// Most streams increase in size when decoded, but Ascii85 streams
|
||||||
// typically shrink by ~20%.
|
// typically shrink by ~20%.
|
||||||
@ -27,7 +29,6 @@ class Ascii85Stream extends DecodeStream {
|
|||||||
|
|
||||||
this.stream = str;
|
this.stream = str;
|
||||||
this.dict = str.dict;
|
this.dict = str.dict;
|
||||||
this.input = new Uint8Array(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readBlock() {
|
readBlock() {
|
||||||
@ -53,12 +54,10 @@ class Ascii85Stream extends DecodeStream {
|
|||||||
// special code for z
|
// special code for z
|
||||||
if (c === Z_LOWER_CHAR) {
|
if (c === Z_LOWER_CHAR) {
|
||||||
buffer = this.ensureBuffer(bufferLength + 4);
|
buffer = this.ensureBuffer(bufferLength + 4);
|
||||||
for (i = 0; i < 4; ++i) {
|
buffer.fill(0, bufferLength, bufferLength + 4);
|
||||||
buffer[bufferLength + i] = 0;
|
|
||||||
}
|
|
||||||
this.bufferLength += 4;
|
this.bufferLength += 4;
|
||||||
} else {
|
} else {
|
||||||
const input = this.input;
|
const input = this.#input;
|
||||||
input[0] = c;
|
input[0] = c;
|
||||||
for (i = 1; i < 5; ++i) {
|
for (i = 1; i < 5; ++i) {
|
||||||
c = str.getByte();
|
c = str.getByte();
|
||||||
@ -77,9 +76,7 @@ class Ascii85Stream extends DecodeStream {
|
|||||||
|
|
||||||
// partial ending;
|
// partial ending;
|
||||||
if (i < 5) {
|
if (i < 5) {
|
||||||
for (; i < 5; ++i) {
|
input.fill(0x21 + 84, i, 5);
|
||||||
input[i] = 0x21 + 84;
|
|
||||||
}
|
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
}
|
}
|
||||||
let t = 0;
|
let t = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user