@@ -16,10 +16,6 @@ inline size_t fast_mod(const size_t i, const size_t c) {
1616 return i >= c ? i % c : i;
1717}
1818
19- inline size_t fast_mod_3 (const size_t i) {
20- return i % 3 ;
21- }
22-
2319// Kahan and Babuska summation, Neumaier variant; accumulates less FP error
2420inline double sum (const std::vector<double >& x) {
2521 double sum = x[0 ];
@@ -152,7 +148,7 @@ inline bool in_circle(
152148
153149constexpr double EPSILON = std::numeric_limits<double >::epsilon();
154150constexpr std::size_t INVALID_INDEX = std::numeric_limits<std::size_t >::max();
155- constexpr std::size_t LEGALIZE_STACK_SIZE = 100 ;
151+ constexpr std::size_t LEGALIZE_STACK_SIZE = 128 ;
156152
157153inline bool check_pts_equal (double x1, double y1, double x2, double y2) {
158154 return std::fabs (x1 - x2) <= EPSILON &&
@@ -484,9 +480,9 @@ std::size_t Delaunator::legalize(std::size_t ia) {
484480 a0 = 3 * (a / 3 ); // a - a % 3;
485481 b0 = 3 * (b / 3 ); // b - b % 3;
486482
487- al = a0 + fast_mod_3 (a + 1 );
488- ar = a0 + fast_mod_3 (a + 2 );
489- bl = b0 + fast_mod_3 (b + 2 );
483+ al = a0 + (a + 1 ) % 3 ;
484+ ar = a0 + (a + 2 ) % 3 ;
485+ bl = b0 + (b + 2 ) % 3 ;
490486
491487 const std::size_t p0 = triangles[ar];
492488 const std::size_t pr = triangles[a];
@@ -528,7 +524,7 @@ std::size_t Delaunator::legalize(std::size_t ia) {
528524 link (b, halfedges[ar]);
529525 link (ar, bl);
530526
531- std::size_t br = b0 + fast_mod_3 (b + 1 );
527+ std::size_t br = b0 + (b + 1 ) % 3 ;
532528
533529 if (i < size) {
534530 // move elements down the stack
0 commit comments