Optimise loops.

This commit is contained in:
Jürg Lehni 2012-11-06 11:28:50 -08:00
parent 16de863aa5
commit e26197cf1f
2 changed files with 4 additions and 5 deletions

View file

@ -106,7 +106,7 @@ var SvgExporter = this.SvgExporter = new function() {
} }
parts.push('M' + formatPoint(segments[0]._point)); 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); addCurve(segments[i], segments[i + 1], false);
// We only need to draw the connecting curve if it is not a line, and if // 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. // 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 'polyline':
case 'polygon': case 'polygon':
var parts = []; var parts = [];
for(i = 0; i < segments.length; i++) for(i = 0, l = segments.length; i < l; i++)
parts.push(formatPoint(segments[i]._point)); parts.push(formatPoint(segments[i]._point));
attrs = { attrs = {
points: parts.join(' ') points: parts.join(' ')

View file

@ -68,9 +68,8 @@ var SvgImporter = this.SvgImporter = new function() {
function importPoly(svg, type) { function importPoly(svg, type) {
var path = new Path(), var path = new Path(),
points = svg.points, points = svg.points;
start = points.getItem(0); path.moveTo(points.getItem(0));
path.moveTo(start);
for (var i = 1, l = points.numberOfItems; i < l; i++) for (var i = 1, l = points.numberOfItems; i < l; i++)
path.lineTo(points.getItem(i)); path.lineTo(points.getItem(i));
if (type === 'polygon') if (type === 'polygon')