Skip to content
Permalink
Browse files
[optimization][geometry snapper] Reserve space needed when appending …
…items to QList<>s
  • Loading branch information
nirvn authored and github-actions committed Apr 27, 2021
1 parent 395e35e commit a0d3b90a9451aab5cbbd42d318416284451ec896
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/analysis/vector/qgsgeometrysnapper.cpp
@@ -197,6 +197,7 @@ QgsSnapIndex::Cell &QgsSnapIndex::GridRow::getCreateCell( int col )
{
if ( col < mColStartIdx )
{
mCells.reserve( mColStartIdx - col );
for ( int i = col; i < mColStartIdx; ++i )
{
mCells.prepend( Cell() );
@@ -206,6 +207,7 @@ QgsSnapIndex::Cell &QgsSnapIndex::GridRow::getCreateCell( int col )
}
else if ( col >= mColStartIdx + mCells.size() )
{
mCells.reserve( col - ( mColStartIdx + mCells.size() ) );
for ( int i = mColStartIdx + mCells.size(); i <= col; ++i )
{
mCells.append( Cell() );
@@ -275,6 +277,7 @@ QgsSnapIndex::Cell &QgsSnapIndex::getCreateCell( int col, int row )
{
if ( row < mRowsStartIdx )
{
mGridRows.reserve( mRowsStartIdx - row );
for ( int i = row; i < mRowsStartIdx; ++i )
{
mGridRows.prepend( GridRow() );
@@ -284,6 +287,7 @@ QgsSnapIndex::Cell &QgsSnapIndex::getCreateCell( int col, int row )
}
else if ( row >= mRowsStartIdx + mGridRows.size() )
{
mGridRows.reserve( row - ( mRowsStartIdx + mGridRows.size() ) );
for ( int i = mRowsStartIdx + mGridRows.size(); i <= row; ++i )
{
mGridRows.append( GridRow() );

0 comments on commit a0d3b90

Please sign in to comment.