Fil / d3-geo-voronoi

Voronoi / Delaunay tessellations on the sphere
ISC License
229 stars 24 forks source link

geo_urquhart() using Map as appropiate. #25

Closed martinfrances107 closed 3 years ago

martinfrances107 commented 3 years ago

as a followup to #24

I ran a global search for "={}" to see if there were anymore examples of a javascript "Object" being used where a more appropriate data structure was available.

I found 2 examples

geo_edges() geo_urquhart()

The CS mantra I am invoking is "Choose the underlying data structure appropriately for the data flow in your design."

The has a subtle benefit that the runtime environment and JIT compiler now has more semantic clues that may lead to more optimal performance.

For example occasionally we might be able to say that if the JIT can look ahead and see a change from a data structure with 5 elements to a data structure with 100 000 elements then it will view to memory storage speed trade-offs differently.

I appreciate that this is all a bit hand wavey, so I am open to criticism on that front. but it is still a change I would like to make.

In this PR I am only fixing geo_urqhart() because the fix I have geo_edges() I think has a backwards compatible breaking change and so that fix should be prepared and reviewed in isolation.

Fil commented 3 years ago

I'm sure there's a lot of performance issues with the current code (#1); having a clearer code is always a win.