mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 12:01:23 +01:00
Optimized Reused Values for Loops
This commit is contained in:
parent
8ec42ca2e5
commit
234fcb09c2
19 changed files with 91 additions and 54 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue