Skip to content

Commit da0234e

Browse files
committed
avoid parsing identical markers for better performance
1 parent b56c6b1 commit da0234e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/components/drawing/symbol_defs.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,22 @@ function skipAngle(angle) {
708708
return angle === null;
709709
}
710710

711+
var lastPathIn, lastPathOut;
712+
var lastAngle, lastStandoff;
713+
711714
function align(angle, standoff, path) {
712715
if((!angle || angle % 360 === 0) && !standoff) return path;
713716

717+
if(
718+
lastAngle === angle &&
719+
lastStandoff === standoff &&
720+
lastPathIn === path
721+
) return lastPathOut;
722+
723+
lastAngle = angle;
724+
lastStandoff = standoff;
725+
lastPathIn = path;
726+
714727
function rotate(t, xy) {
715728
var cosT = cos(t);
716729
var sinT = sin(t);
@@ -787,5 +800,7 @@ function align(angle, standoff, path) {
787800
str += cmdI[0] + cmdI.slice(1).join(',');
788801
}
789802

803+
lastPathOut = str;
804+
790805
return str;
791806
}

0 commit comments

Comments
 (0)