Skip to content

Commit b4e8ef5

Browse files
committed
Expand "hash table" size by the golden ratio.
1 parent 6f28799 commit b4e8ef5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/delaunator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,8 @@ Delaunator::Delaunator(std::vector<double> const& in_coords)
305305
{ return dists[i] < dists[j]; });
306306

307307
// initialize a hash table for storing edges of the advancing convex hull
308-
m_hash_size = static_cast<std::size_t>(std::ceil(std::sqrt(n)));
308+
// 1.618 is the golden ratio.
309+
m_hash_size = static_cast<std::size_t>(1.618 * std::ceil(std::sqrt(n)));
309310
m_hash.resize(m_hash_size);
310311
std::fill(m_hash.begin(), m_hash.end(), INVALID_INDEX);
311312

0 commit comments

Comments
 (0)