flauwekeul/honeycomb

Why is Grid.get so slow?

eranimo opened this issue · 4 comments

Calling Grid.get in a loop seems to be extremely slow. It appears that its looping over the entire grid. Why? Seems unnecessary.

When you call get() with a number (the index of a hex in the grid) it should be very fast (same as grid[index]). When you call it with anything that can be converted to a Point (e.g. [1, 2], { x: 1, y: 2 }) it does indeed loop over the grid until it finds the hex with those cartesian coordinates.

I'm working on a rewrite of the project where these kinds of operations (finding 1 or more hexes in a grid) can be fine-tuned way more easily. I hope to release an alpha version in a month or so.

Sounds great, thanks!

Closing this because it seems your question was answered satisfactory.

Just to let you know: I've released an alpha version with a new API! Please check out the next branch.