From bae3394457a23a0e7a9c0d2b56727f1fd16f1680 Mon Sep 17 00:00:00 2001 From: Mahesh Madhav Date: Thu, 26 Sep 2024 03:24:29 +0000 Subject: [PATCH 1/2] Optimization in getEdgeHexagons Replace 4 fpdiv's with 1 fpdiv and 4 fpmul's --- src/h3lib/lib/algos.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/h3lib/lib/algos.c b/src/h3lib/lib/algos.c index 949988a08..1b20bf5ef 100644 --- a/src/h3lib/lib/algos.c +++ b/src/h3lib/lib/algos.c @@ -837,12 +837,13 @@ H3Error _getEdgeHexagons(const GeoLoop *geoloop, int64_t numHexagons, int res, } for (int64_t j = 0; j < numHexesEstimate; j++) { LatLng interpolate; + double invNumHexesEst = 1.0 / numHexesEstimate; interpolate.lat = - (origin.lat * (numHexesEstimate - j) / numHexesEstimate) + - (destination.lat * j / numHexesEstimate); + (origin.lat * (numHexesEstimate - j) * invNumHexesEst) + + (destination.lat * j * invNumHexesEst); interpolate.lng = - (origin.lng * (numHexesEstimate - j) / numHexesEstimate) + - (destination.lng * j / numHexesEstimate); + (origin.lng * (numHexesEstimate - j) * invNumHexesEst) + + (destination.lng * j * invNumHexesEst); H3Index pointHex; H3Error e = H3_EXPORT(latLngToCell)(&interpolate, res, &pointHex); if (e) { From 9a157d87d23e0504a61d062c79b7ff861b8e4b0c Mon Sep 17 00:00:00 2001 From: Mahesh Madhav Date: Thu, 26 Sep 2024 17:22:16 +0000 Subject: [PATCH 2/2] Updated changelog to add #913 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d29dd51d9..4711b4dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The public API of this library consists of the functions declared in file ### Changed - Replace internal algorithm for `polygonToCells` with a new version that is more memory-efficient (#785) - Reorganize tests into public / internal. (#762) -- Performance enhancement for aarch64, may improve other platforms (#790, #792, #852, #905) +- Performance enhancement for aarch64, may improve other platforms (#790, #792, #852, #905, #913) - `clang-format` upgraded to version 14. (#834) - Fixed tests that incorrectly did not test resolution 15. (#820) - Use `CMAKE_INSTALL_LIBDIR` when choosing where to install library files. (#819)