Skip to content

Commit 7397a41

Browse files
authored
Change remaining for of loops to regular ones (#7103)
1 parent 8245da4 commit 7397a41

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/helpers/helpers.segment.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ export function _boundSegment(segment, points, bounds) {
122122
*/
123123
export function _boundSegments(line, bounds) {
124124
const result = [];
125+
const segments = line.segments;
125126

126-
for (const segment of line.segments) {
127-
const sub = _boundSegment(segment, line.points, bounds);
127+
for (let i = 0; i < segments.length; i++) {
128+
const sub = _boundSegment(segments[i], line.points, bounds);
128129
if (sub.length) {
129130
result.push(...sub);
130131
}

src/plugins/plugin.filler.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ function _getEdge(a, b, prop, fn) {
265265
}
266266

267267
function _segments(line, target, property) {
268+
const segments = line.segments;
268269
const points = line.points;
269270
const tpoints = target.points;
270271
const parts = [];
@@ -280,7 +281,8 @@ function _segments(line, target, property) {
280281
}
281282
}
282283

283-
for (const segment of line.segments) {
284+
for (let i = 0; i < segments.length; i++) {
285+
const segment = segments[i];
284286
const bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop);
285287

286288
if (!target.segments) {
@@ -298,13 +300,14 @@ function _segments(line, target, property) {
298300
// Get all segments from `target` that intersect the bounds of current segment of `line`
299301
const subs = _boundSegments(target, bounds);
300302

301-
for (const sub of subs) {
303+
for (let j = 0; j < subs.length; ++j) {
304+
const sub = subs[j];
302305
const subBounds = getBounds(property, tpoints[sub.start], tpoints[sub.end], sub.loop);
303306
const fillSources = _boundSegment(segment, points, subBounds);
304307

305-
for (const source of fillSources) {
308+
for (let k = 0; k < fillSources.length; k++) {
306309
parts.push({
307-
source,
310+
source: fillSources[k],
308311
target: sub,
309312
start: {
310313
[property]: _getEdge(bounds, subBounds, 'start', Math.max)

0 commit comments

Comments
 (0)