mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Replace loop with TypedArray.prototype.set
in the DecryptStream.readBlock
method
There's no reason to use a manual loop, when a native method exists.
This commit is contained in:
parent
7d5f7a517c
commit
6877d8b9e2
1 changed files with 5 additions and 7 deletions
|
@ -46,13 +46,11 @@ class DecryptStream extends DecodeStream {
|
|||
const decrypt = this.decrypt;
|
||||
chunk = decrypt(chunk, !hasMoreData);
|
||||
|
||||
let bufferLength = this.bufferLength;
|
||||
const n = chunk.length,
|
||||
buffer = this.ensureBuffer(bufferLength + n);
|
||||
for (let i = 0; i < n; i++) {
|
||||
buffer[bufferLength++] = chunk[i];
|
||||
}
|
||||
this.bufferLength = bufferLength;
|
||||
const bufferLength = this.bufferLength,
|
||||
newLength = bufferLength + chunk.length,
|
||||
buffer = this.ensureBuffer(newLength);
|
||||
buffer.set(chunk, bufferLength);
|
||||
this.bufferLength = newLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue