[geos-commits] [SCM] GEOS branch main updated. c2a1d40c2d86f0b6f8028d4965ffa2aef79473d7

git at osgeo.org git at osgeo.org
Mon Dec 1 09:25:18 PST 2025


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main has been updated
       via  c2a1d40c2d86f0b6f8028d4965ffa2aef79473d7 (commit)
      from  c0b00fc4a4b3a33dd16c4266f247dbf931241564 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c2a1d40c2d86f0b6f8028d4965ffa2aef79473d7
Author: Sven Jensen <sven at analysis.net>
Date:   Mon Dec 1 09:24:48 2025 -0800

    SIMD vectorization of Length.cpp, up to 2.8x faster
    
    Enables the SIMD vectorization of the line-length loop when HAVE_OPEN_SIMD is defined.

diff --git a/src/algorithm/Length.cpp b/src/algorithm/Length.cpp
index 68897dac4..64087b6bc 100644
--- a/src/algorithm/Length.cpp
+++ b/src/algorithm/Length.cpp
@@ -35,22 +35,15 @@ Length::ofLine(const geom::CoordinateSequence* pts)
     }
 
     double len = 0.0;
-
-    const geom::CoordinateXY& p = pts->getAt<geom::CoordinateXY>(0);
-    double x0 = p.x;
-    double y0 = p.y;
-
+    
     for(std::size_t i = 1; i < n; i++) {
         const geom::CoordinateXY& pi = pts->getAt<geom::CoordinateXY>(i);
-        double x1 = pi.x;
-        double y1 = pi.y;
-        double dx = x1 - x0;
-        double dy = y1 - y0;
+        const geom::CoordinateXY& pi_1 = pts->getAt<geom::CoordinateXY>(i-1);
+        
+        double dx = pi.x - pi_1.x;
+        double dy = pi.y - pi_1.y;
 
         len += std::sqrt(dx * dx + dy * dy);
-
-        x0 = x1;
-        y0 = y1;
     }
     return len;
 }
@@ -63,20 +56,15 @@ Length::ofLine(const std::vector<geom::CoordinateXY>& pts)
     }
 
     double len = 0;
-    double x0 = pts[0].x;
-    double y0 = pts[0].y;
-
+    
     for(std::size_t i = 1; i < pts.size(); i++) {
         const geom::CoordinateXY& pi = pts[i];
-        double x1 = pi.x;
-        double y1 = pi.y;
-        double dx = x1 - x0;
-        double dy = y1 - y0;
+        const geom::CoordinateXY& pi_1 = pts[i-1];
+        
+        double dx = pi.x - pi_1.x;
+        double dy = pi.y - pi_1.y;
 
         len += std::sqrt(dx * dx + dy * dy);
-
-        x0 = x1;
-        y0 = y1;
     }
 
     return len;

-----------------------------------------------------------------------

Summary of changes:
 src/algorithm/Length.cpp | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list