Skip to content
Permalink
Browse files

Optimise QgsLineString::calculateBoundingBox

  • Loading branch information
nyalldawson committed Feb 23, 2021
1 parent d007901 commit 43cbe1e6278807084150e08a54fe4f789de710af
Showing with 11 additions and 13 deletions.
  1. +11 −13 src/core/geometry/qgslinestring.cpp
@@ -453,21 +453,19 @@ QgsRectangle QgsLineString::calculateBoundingBox() const
double xmax = -std::numeric_limits<double>::max();
double ymax = -std::numeric_limits<double>::max();

for ( double x : mX )
{
if ( x < xmin )
xmin = x;
if ( x > xmax )
xmax = x;
}
for ( double y : mY )
const int nb = mX.size();
const double *x = mX.constData();
const double *y = mY.constData();
for ( int i = 0; i < nb; ++i )
{
if ( y < ymin )
ymin = y;
if ( y > ymax )
ymax = y;
const double px = *x++;
xmin = std::min( xmin, px );
xmax = std::max( xmax, px );
const double py = *y++;
ymin = std::min( ymin, py );
ymax = std::max( ymax, py );
}
return QgsRectangle( xmin, ymin, xmax, ymax );
return QgsRectangle( xmin, ymin, xmax, ymax, false );
}

/***************************************************************************

0 comments on commit 43cbe1e

Please sign in to comment.