@@ -395,8 +395,8 @@ function findBezierIntersections(bez1, bez2, justCount) {
395395 * @return {import("./intersect").Intersection[] | number }
396396 */
397397export default function findPathIntersections ( path1 , path2 , justCount ) {
398- path1 = getPathCurve ( path1 ) ;
399- path2 = getPathCurve ( path2 ) ;
398+ path1 = path1 . parsed ? path1 : getPathCurve ( path1 ) ;
399+ path2 = path2 . parsed ? path2 : getPathCurve ( path2 ) ;
400400
401401 var x1 , y1 , x2 , y2 , x1m , y1m , x2m , y2m , bez1 , bez2 ,
402402 res = justCount ? 0 : [ ] ;
@@ -766,7 +766,7 @@ function curveBBox(x0, y0, x1, y1, x2, y2, x3, y3) {
766766}
767767
768768/**
769- * Handles caches
769+ * An impure version of { @link parsePathCurve} handling caching
770770 */
771771function getPathCurve ( path ) {
772772
@@ -795,6 +795,36 @@ function getPathCurve(path) {
795795 return ( pth . curve = pathToCurve ( abs ) ) ;
796796}
797797
798+ /**
799+ * A pure version of {@link getPathCurve}
800+ * @param {import("./intersect").Path } path
801+ * @returns {import("./intersect").PathComponent[] }
802+ */
803+ export function parsePathCurve ( path ) {
804+
805+ const abs = ( pathToAbsolute (
806+ ! Array . isArray ( path ) ?
807+ parsePathString ( path ) :
808+ path )
809+ ) ;
810+
811+ const curve = pathToCurve ( abs ) ;
812+
813+ /**
814+ * Flag to skip {@link getPathCurve}
815+ */
816+ return Object . defineProperty (
817+ curve ,
818+ 'parsed' ,
819+ {
820+ value : true ,
821+ configurable : false ,
822+ enumerable : false ,
823+ writable : false
824+ }
825+ ) ;
826+ }
827+
798828function pathToCurve ( absPath ) {
799829
800830 var curvedPath = pathClone ( absPath ) ,
0 commit comments