Skip to content

Commit

Permalink
Merge pull request #19456 from Snuffleupagus/more-TypedArray-fill
Browse files Browse the repository at this point in the history
Replace a couple of loops with `TypedArray.prototype.fill()`
  • Loading branch information
Snuffleupagus authored Feb 9, 2025
2 parents 6862e84 + 294fa3e commit b4a6b1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/core/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,9 @@ class PDFFunction {
// Building the cube vertices: its part and sample index
// http://rjwagner49.com/Mathematics/Interpolation.pdf
const cubeVertices = 1 << inputSize;
const cubeN = new Float64Array(cubeVertices);
const cubeN = new Float64Array(cubeVertices).fill(1);
const cubeVertex = new Uint32Array(cubeVertices);
let i, j;
for (j = 0; j < cubeVertices; j++) {
cubeN[j] = 1;
}

let k = outputSize,
pos = 1;
Expand Down
8 changes: 2 additions & 6 deletions src/core/jbig2.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,7 @@ function decodeTextRegion(
for (i = 0; i < height; i++) {
row = new Uint8Array(width);
if (defaultPixelValue) {
for (let j = 0; j < width; j++) {
row[j] = defaultPixelValue;
}
row.fill(defaultPixelValue);
}
bitmap.push(row);
}
Expand Down Expand Up @@ -1041,9 +1039,7 @@ function decodeHalftoneRegion(
for (i = 0; i < regionHeight; i++) {
row = new Uint8Array(regionWidth);
if (defaultPixelValue) {
for (j = 0; j < regionWidth; j++) {
row[j] = defaultPixelValue;
}
row.fill(defaultPixelValue);
}
regionBitmap.push(row);
}
Expand Down

0 comments on commit b4a6b1b

Please sign in to comment.