Closed mbostock closed 5 years ago
Yeah, adding an update
method would allow us to avoid repeated allocation of these two arrays:
https://github.com/d3/d3-delaunay/blob/86be03cbd6ddab360bb441402900fb4956375b09/src/voronoi.js#L8-L9
triangles
may slightly vary from update to update, but is close to the max (2 * numPoints - 5
), so we could do the same trick as Delaunator — allocate a maximum length circumcenters array as a private property and then expose a trimmed one as voronoi.circumcenters
, referencing the same memory (with subarray
).
Works great! ❤️
How is delaunay.update supposed to interact with delaunay.voronoi? I assume you are expected to call delaunay.voronoi again after calling delaunay.update, but it’d be nice if there were an equivalent voronoi.update method.