From f9d259a3d85177649992e0248fd2daa183a50093 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Fri, 29 Sep 2023 11:48:26 -0700 Subject: [PATCH] Removes redundant function evaluation in numeric integration --- src/ifcgeom/mapping/IfcCurveSegment.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index 88d02f527b..55d5edda80 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -41,13 +41,16 @@ namespace { double area = 0; double h = (b - a) / n; + auto x1 = a; + auto f1 = fn(x1); for (auto i = 1; i <= n; i++) { - auto x1 = a + h * (i - 1); auto x2 = a + h * i; - auto f1 = fn(x1); auto f2 = fn(x2); area += h * (f1 + f2) / 2.0; + + x1 = x2; + f1 = f2; } return area; }