Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[optimization][geometry snapper] Reserve space needed when appending …
…items to QList<>s
  • Loading branch information
nirvn committed Apr 19, 2021
1 parent 68a4b52 commit ec971e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Expand Up @@ -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() );
Expand All @@ -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() );
Expand Down Expand Up @@ -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() );
Expand All @@ -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() );
Expand Down

0 comments on commit ec971e3

Please sign in to comment.