4 ms·
Another optimization would be to compare square of distance instead of distance, saving "Math.sqrt" call each iteration.
by colgate_total 4y ago
Another optimization would be to compare square of distance instead of distance, saving "Math.sqrt" call each iteration.
- geraldwhen 4y agoMath.sqrt in a big loop is surprisingly slow. You learn this 0.2 seconds into game development, but I ran into it in a business context recently. 3% of a large cpu intensive runtime was sqrt.