Faster
Fil opened this issue · 4 comments
Fil commented
Ideas for later:
- change the arrays into typed arrays when possible (edges => edges2, etc) in the delaunay part
use spherical trig for rotation & projection (instead of geoRotation+geoStereographic)✓use spherical trig for checking if a triangle is clockwise or CCW (instead of geoArea!)✓
mbostock commented
Another small optimization is using d3.geoStereographicRaw (or inline the definition) instead of d3.geoStereographic.
mourner commented
Skimming through the code, I also recommend:
- Using flat arrays for points — e.g.
[x, y, x, y, ...
instead of[[x, y], [x, y], ...
. - Avoiding array allocations as much as possible. This includes chained
array.map
andslice
. Inspect each occurrence of allocating methods and try to rewrite for less allocations (e.g. collapse chained function-style transformation into a single for loop).
Fil commented
A good reference presentation :)
https://www.dotconferences.com/2019/12/vladimir-agafonkin-algorithmic-performance-optimization-in-practice