From 0a73a6452039274193dd93af32b8ef19c334e10e Mon Sep 17 00:00:00 2001 From: liabru Date: Thu, 21 May 2015 00:07:30 +0100 Subject: [PATCH] skip unnecessary loops in Composites.mesh, closes #85 --- src/factory/Composites.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/factory/Composites.js b/src/factory/Composites.js index f74acfe..63d9607 100644 --- a/src/factory/Composites.js +++ b/src/factory/Composites.js @@ -119,16 +119,14 @@ var Composites = {}; bodyC; for (row = 0; row < rows; row++) { - for (col = 0; col < columns; col++) { - if (col > 0) { - bodyA = bodies[(col - 1) + (row * columns)]; - bodyB = bodies[col + (row * columns)]; - Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); - } + for (col = 1; col < columns; col++) { + bodyA = bodies[(col - 1) + (row * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); } - for (col = 0; col < columns; col++) { - if (row > 0) { + if (row > 0) { + for (col = 0; col < columns; col++) { bodyA = bodies[col + ((row - 1) * columns)]; bodyB = bodies[col + (row * columns)]; Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options)));