Skip to content

Commit 89d2af2

Browse files
committed
remove fast_mod_3
1 parent 3b2290b commit 89d2af2

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

bench/run.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ void BM_uniform(benchmark::State& state) {
3434
}
3535

3636
BENCHMARK(BM_45K_geojson_nodes)->Unit(benchmark::kMillisecond);
37-
BENCHMARK(BM_uniform)->Arg(2000)->Arg(100000)->Arg(200000)->Arg(500000)->Arg(1000000)->Unit(benchmark::kMillisecond);
37+
BENCHMARK(BM_uniform)->Arg(2000)->Arg(100000)->Arg(200000)->Arg(500000)->Arg(1000000)->Arg(100000000)->Unit(benchmark::kMillisecond);
3838

3939
BENCHMARK_MAIN()

include/delaunator.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2420
inline double sum(const std::vector<double>& x) {
2521
double sum = x[0];
@@ -152,7 +148,7 @@ inline bool in_circle(
152148

153149
constexpr double EPSILON = std::numeric_limits<double>::epsilon();
154150
constexpr 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

157153
inline 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

Comments
 (0)