Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
gindevine
on Dec 31, 2010
|
parent
|
context
|
favorite
| on:
I benchmarked 8 different ways of representing a 2...
When creating a 2d grid array with all values the same, slicing one row multiple times works way faster than creating each row for each column.
for(var y=h;y>=0; y--) row.push(0); for(var x=w; x>=0; x--) grid[x] = row.slice(0);
It seems to me that this method should work without any problems, but I may be wrong..
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: