> (x*x >= y*y)
Wait, JS engines are smart enough to optimize this to branchless instructions producting 1 or 0?
(also, if you're working at that level of optimization, wouldn't it make sense to do the x*x and y*y calculation up-front, as well as a `const {round} = Math` to reduce hashtable lookups?)
I had Math.abs(x) >= Math.abs(y) before, but this is more compact. The cost of the floating point multiplication vs. absolute value is about the same I think. When a sub-expression is repeated (like x*x or y*y) the JITs are smart enough not to do the work twice.
as for `const {round} = Math`, my understanding is that can actually make code slower. The JITs have some special-case logic for built-in math functions.
None of these changes make any apparent speed difference (including conditional vs. arithmetic, making a shortcut to `round`, doing 1 vs. 2 comparisons, etc. I haven’t investigated too deeply but I suspect the creation of the output array is significantly slower than any of the arithmetic here.