Merge pull request #11334 from Snuffleupagus/FlateStream-readBlock-getBytes

Use `getBytes`, rather than looping over `getByte`, in `FlateStream.prototype.readBlock`
This commit is contained in:
Tim van der Meij 2019-11-16 13:50:40 +01:00 committed by GitHub
commit 789c2c6a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -580,21 +580,19 @@ var FlateStream = (function FlateStreamClosure() {
this.codeBuf = 0;
this.codeSize = 0;
var bufferLength = this.bufferLength;
buffer = this.ensureBuffer(bufferLength + blockLen);
var end = bufferLength + blockLen;
const bufferLength = this.bufferLength, end = bufferLength + blockLen;
buffer = this.ensureBuffer(end);
this.bufferLength = end;
if (blockLen === 0) {
if (str.peekByte() === -1) {
this.eof = true;
}
} else {
for (var n = bufferLength; n < end; ++n) {
if ((b = str.getByte()) === -1) {
this.eof = true;
break;
}
buffer[n] = b;
const block = str.getBytes(blockLen);
buffer.set(block, bufferLength);
if (block.length < blockLen) {
this.eof = true;
}
}
return;