Change remaining for of loops to regular ones (#7103)

This commit is contained in:
Jukka Kurkela 2020-02-14 21:12:23 +02:00 committed by GitHub
parent 8245da44f5
commit 7397a41fac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -122,9 +122,10 @@ export function _boundSegment(segment, points, bounds) {
*/
export function _boundSegments(line, bounds) {
const result = [];
const segments = line.segments;
for (const segment of line.segments) {
const sub = _boundSegment(segment, line.points, bounds);
for (let i = 0; i < segments.length; i++) {
const sub = _boundSegment(segments[i], line.points, bounds);
if (sub.length) {
result.push(...sub);
}

View File

@ -265,6 +265,7 @@ function _getEdge(a, b, prop, fn) {
}
function _segments(line, target, property) {
const segments = line.segments;
const points = line.points;
const tpoints = target.points;
const parts = [];
@ -280,7 +281,8 @@ function _segments(line, target, property) {
}
}
for (const segment of line.segments) {
for (let i = 0; i < segments.length; i++) {
const segment = segments[i];
const bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop);
if (!target.segments) {
@ -298,13 +300,14 @@ function _segments(line, target, property) {
// Get all segments from `target` that intersect the bounds of current segment of `line`
const subs = _boundSegments(target, bounds);
for (const sub of subs) {
for (let j = 0; j < subs.length; ++j) {
const sub = subs[j];
const subBounds = getBounds(property, tpoints[sub.start], tpoints[sub.end], sub.loop);
const fillSources = _boundSegment(segment, points, subBounds);
for (const source of fillSources) {
for (let k = 0; k < fillSources.length; k++) {
parts.push({
source,
source: fillSources[k],
target: sub,
start: {
[property]: _getEdge(bounds, subBounds, 'start', Math.max)