Skip to content

Commit

Permalink
Replace a loop with TypedArray.prototype.fill() in the `RunLengthSt…
Browse files Browse the repository at this point in the history
…ream` class

This is a tiny bit shorter, which cannot hurt.
  • Loading branch information
Snuffleupagus committed Mar 2, 2025
1 parent 89ccc3a commit a3d259a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/run_length_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ class RunLengthStream extends DecodeStream {
}
} else {
n = 257 - n;
const b = repeatHeader[1];
buffer = this.ensureBuffer(bufferLength + n + 1);
for (let i = 0; i < n; i++) {
buffer[bufferLength++] = b;
}
buffer.fill(repeatHeader[1], bufferLength, bufferLength + n);
bufferLength += n;
}
this.bufferLength = bufferLength;
}
Expand Down

0 comments on commit a3d259a

Please sign in to comment.