mitsuhiko/webgl-meincraft — comment on commit 218b83bec1d08fbdfdff8f36e4a56d56f9591ee2
File: src/world.coffee line 182
By chrisdickinson:

this could be made faster by adding a

````coffee
for cz in [0... @chunkSize] by 1
...
````

coffeescript, by default, doesn't know which direction the loop will take, and compiles the code-as-it-exists to

````javascript

var cx, cy, cz;
for (cz = 0; 0 <= chunkSize ? cz < chunkSize : cz > chunkSize; 0 <= chunkSize ? cz++ : cz--) {
for (cy = 0; 0 <= chunkSize ? cy < chunkSize : cy > chunkSize; 0 <= chunkSize ? cy++ : cy--) {
for (cx = 0; 0 <= chunkSize ? cx < chunkSize : cx > chunkSize; 0 <= chunkSize ? cx++ : cx--) {
console.log(cx, cy, cz);
}
}
}

````

so, two extra if statements per loop iteration. blegh! this may not be a colossal improvement, but you might check to see where else this sort of thing is happening.