Merge pull request #21560 from Snuffleupagus/more-for-of-3

Use `for...of` even more in the code-base
This commit is contained in:
Tim van der Meij 2026-07-11 18:14:46 +02:00 committed by GitHub
commit 54af145989
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 14 additions and 18 deletions

View File

@ -4792,19 +4792,19 @@ class InkAnnotation extends MarkupAnnotation {
if (!Array.isArray(rawInkLists)) {
return;
}
for (let i = 0, ii = rawInkLists.length; i < ii; ++i) {
for (const rawInkList of rawInkLists) {
// The raw ink lists array contains arrays of numbers representing
// the alternating horizontal and vertical coordinates, respectively,
// of each vertex. Convert this to an array of objects with x and y
// coordinates.
if (!Array.isArray(rawInkLists[i])) {
if (!Array.isArray(rawInkList)) {
continue;
}
const inkList = new Float32Array(rawInkLists[i].length);
const inkList = new Float32Array(rawInkList.length);
this.data.inkLists.push(inkList);
for (let j = 0, jj = rawInkLists[i].length; j < jj; j += 2) {
const x = xref.fetchIfRef(rawInkLists[i][j]),
y = xref.fetchIfRef(rawInkLists[i][j + 1]);
for (let j = 0, jj = rawInkList.length; j < jj; j += 2) {
const x = xref.fetchIfRef(rawInkList[j]),
y = xref.fetchIfRef(rawInkList[j + 1]);
if (typeof x === "number" && typeof y === "number") {
inkList[j] = x;
inkList[j + 1] = y;

View File

@ -200,8 +200,7 @@ async function createImage(bitmap, xref, { closeBitmap = false } = {}) {
const colorCounter = new Set();
let hasAlpha = false;
let useFlate = true;
for (let i = 0, ii = buf32.length; i < ii; i++) {
const v = buf32[i];
for (const v of buf32) {
if ((isLE ? v >>> 24 : v & 0xff) !== 0xff) {
hasAlpha = true;
break;

View File

@ -3273,9 +3273,7 @@ class PartialEvaluator {
const spaceFactor =
((textState.font.vertical ? 1 : -1) * textState.fontSize) / 1000;
const elements = args[0];
for (let i = 0, ii = elements.length; i < ii; i++) {
const item = elements[i];
for (const item of args[0]) {
if (typeof item === "string") {
showSpacedTextBuffer.push(item);
} else if (typeof item === "number" && item !== 0) {

View File

@ -1525,9 +1525,9 @@ class Font {
}
const [nameTable] = readNameTable(potentialTables.name);
for (let j = 0, jj = nameTable.length; j < jj; j++) {
for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
const nameEntry = nameTable[j][k]?.replaceAll(/\s/g, "");
for (const nameArr of nameTable) {
for (const entry of nameArr) {
const nameEntry = entry?.replaceAll(/\s/g, "");
if (!nameEntry) {
continue;
}

View File

@ -3517,10 +3517,10 @@ class InkAnnotationElement extends AnnotationElement {
g.setAttribute("fill", "transparent");
g.setAttribute("transform", transform);
for (let i = 0, ii = inkLists.length; i < ii; i++) {
for (const inkList of inkLists) {
const polyline = this.svgFactory.createElement(this.svgElementName);
this.#polylines.push(polyline);
polyline.setAttribute("points", inkLists[i].join(","));
polyline.setAttribute("points", inkList.join(","));
g.append(polyline);
}

View File

@ -517,8 +517,7 @@ class Stepper {
return 0;
});
for (let i = 0; i < operatorsGroupsByZindex.length; i++) {
const group = operatorsGroupsByZindex[i];
for (const group of operatorsGroupsByZindex) {
if (group.minX !== null) {
const el = this.#c("div");
el.style.left = `${group.minX * 100}%`;