Faster than earcut: triangulating 3.7M map polygons in 489 ms
Posted by molind 1 hour ago
Comments
Comment by foxhill 44 seconds ago
either way, neat stuff, and the write up itself is excellent.
Comment by willtemperley 3 minutes ago
Comment by amelius 35 minutes ago
Comment by n4r9 16 minutes ago
Comment by mourner 16 minutes ago
One thing to note is that I deliberately had to reject some of the potential optimizations to keep the library small, so that bundle size doesn't blow up — for most practical applications (e.g. Mapbox GL JS), it's already fast enough (and 4.1k min/gz). Curious how big the WASM build of Earstrip is.
On the C++ side, Mapbox now uses a hybrid approach where small polygons are processed with earcut.hpp, while big and complex polygon switch to a different algorithm based on monotone decomposition, because while it has higher constants in algorithmic complexity, it scales much better with input size.
Comment by swiftcoder 39 minutes ago
Comment by entrope 15 minutes ago
My experience is that Claude Opus 5 and 5.5 are very good at implementing optimizations, reasonably good at suggesting approaches to try, and not very inclined to identify slow runtime as a problem. It tends to go for simple implementations until I ask about speed, which is certainly conventional wisdom for development.
Comment by deakmisra 47 minutes ago