Optimized Reused Values for Loops

This commit is contained in:
Onyx Azryn 2020-10-10 08:33:24 -05:00
parent 8ec42ca2e5
commit 234fcb09c2
19 changed files with 91 additions and 54 deletions

View file

@ -70,13 +70,14 @@
bodies.forEach(function(f) {
const ports = allPorts.filter(b => b.port === f); // all ports on the same feature
if (ports.length < 2) return;
let numberOfPorts = ports.length;
if (numberOfPorts < 2) return;
for (let s=0; s < ports.length; s++) {
for (let s=0; s < numberOfPorts; s++) {
const source = ports[s].cell;
if (connected[source]) continue;
for (let t=s+1; t < ports.length; t++) {
for (let t=s+1; t < numberOfPorts; t++) {
const target = ports[t].cell;
if (connected[target]) continue;