Skip to content

Commit

Permalink
[geometry snapper] More QList micro optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored and github-actions[bot] committed Apr 27, 2021
1 parent a0d3b90 commit 7ff626e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Expand Up @@ -228,7 +228,7 @@ const QgsSnapIndex::Cell *QgsSnapIndex::GridRow::getCell( int col ) const
}
else
{
return &mCells[col - mColStartIdx];
return &mCells.at( col - mColStartIdx );
}
}

Expand All @@ -238,10 +238,10 @@ QList<QgsSnapIndex::SnapItem *> QgsSnapIndex::GridRow::getSnapItems( int colStar
colEnd = std::min( colEnd, mColStartIdx + mCells.size() - 1 );

QList<SnapItem *> items;

items.reserve( colEnd - colStart + 1 );
for ( int col = colStart; col <= colEnd; ++col )
{
items.append( mCells[col - mColStartIdx] );
items.append( mCells.at( col - mColStartIdx ) );
}
return items;
}
Expand Down Expand Up @@ -269,7 +269,7 @@ const QgsSnapIndex::Cell *QgsSnapIndex::getCell( int col, int row ) const
}
else
{
return mGridRows[row - mRowsStartIdx].getCell( col );
return mGridRows.at( row - mRowsStartIdx ).getCell( col );
}
}

Expand Down Expand Up @@ -410,9 +410,10 @@ QgsSnapIndex::SnapItem *QgsSnapIndex::getSnapItem( const QgsPoint &pos, double t
rowEnd = std::min( rowEnd, mRowsStartIdx + mGridRows.size() - 1 );

QList<SnapItem *> items;
items.reserve( rowEnd - rowStart + 1 );
for ( int row = rowStart; row <= rowEnd; ++row )
{
items.append( mGridRows[row - mRowsStartIdx].getSnapItems( colStart, colEnd ) );
items.append( mGridRows.at( row - mRowsStartIdx ).getSnapItems( colStart, colEnd ) );
}

double minDistSegment = std::numeric_limits<double>::max();
Expand Down

0 comments on commit 7ff626e

Please sign in to comment.