From e26197cf1f4ffc08c30908b8d5c642ff34ec9ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 6 Nov 2012 11:28:50 -0800 Subject: [PATCH] Optimise loops. --- src/svg/SvgExporter.js | 4 ++-- src/svg/SvgImporter.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/svg/SvgExporter.js b/src/svg/SvgExporter.js index ca4e686a..ec49241d 100644 --- a/src/svg/SvgExporter.js +++ b/src/svg/SvgExporter.js @@ -106,7 +106,7 @@ var SvgExporter = this.SvgExporter = new function() { } parts.push('M' + formatPoint(segments[0]._point)); - for (i = 0; i < segments.length - 1; i++) + for (i = 0, l = segments.length - 1; i < l; i++) addCurve(segments[i], segments[i + 1], false); // We only need to draw the connecting curve if it is not a line, and if // the path is cosed and has a stroke color, or if it is filled. @@ -238,7 +238,7 @@ var SvgExporter = this.SvgExporter = new function() { case 'polyline': case 'polygon': var parts = []; - for(i = 0; i < segments.length; i++) + for(i = 0, l = segments.length; i < l; i++) parts.push(formatPoint(segments[i]._point)); attrs = { points: parts.join(' ') diff --git a/src/svg/SvgImporter.js b/src/svg/SvgImporter.js index 4cd57254..f68e2438 100644 --- a/src/svg/SvgImporter.js +++ b/src/svg/SvgImporter.js @@ -68,9 +68,8 @@ var SvgImporter = this.SvgImporter = new function() { function importPoly(svg, type) { var path = new Path(), - points = svg.points, - start = points.getItem(0); - path.moveTo(start); + points = svg.points; + path.moveTo(points.getItem(0)); for (var i = 1, l = points.numberOfItems; i < l; i++) path.lineTo(points.getItem(i)); if (type === 'polygon')