Skip to content

Commit 74c7a5b

Browse files
committed
refactor(findBezierIntersections): extract bezierBBoxIntersects
1 parent 96840db commit 74c7a5b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

intersect.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,14 @@ function fixError(number) {
299299
return Math.round(number * 100000000000) / 100000000000;
300300
}
301301

302-
function findBezierIntersections(bez1, bez2, justCount) {
302+
function bezierBBoxIntersects(bez1, bez2) {
303303
var bbox1 = bezierBBox(bez1),
304304
bbox2 = bezierBBox(bez2);
305305

306-
if (!isBBoxIntersect(bbox1, bbox2)) {
307-
return justCount ? 0 : [];
308-
}
306+
return isBBoxIntersect(bbox1, bbox2);
307+
}
308+
309+
function findBezierIntersections(bez1, bez2, justCount) {
309310

310311
// As an optimization, lines will have only 1 segment
311312

@@ -448,7 +449,9 @@ export default function findPathIntersections(path1, path2, justCount) {
448449
y2 = y2m;
449450
}
450451

451-
var intr = findBezierIntersections(bez1, bez2, justCount);
452+
var intr = bezierBBoxIntersects(bez1, bez2) ?
453+
findBezierIntersections(bez1, bez2, justCount) :
454+
justCount ? 0 : [];
452455

453456
if (justCount) {
454457
res += intr;

0 commit comments

Comments
 (0)