aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-10-16 09:23:21 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-16 09:23:21 -0700
commit4ba7686eb79a06b7165c007b41cd0cf7bb3ddb2d (patch)
tree8742c564020a1a610725cada3558b4cfc8a85d68 /src
parent71b5628a37fb4eccd1071bb8ecd43c6fae5ad7b8 (diff)
Tweak out SkTileGrid::insert() loop.
Diffstat (limited to 'src')
-rw-r--r--src/core/SkTileGrid.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp
index fd00253097..10782c4d6d 100644
--- a/src/core/SkTileGrid.cpp
+++ b/src/core/SkTileGrid.cpp
@@ -84,10 +84,15 @@ void SkTileGrid::insert(unsigned opIndex, const SkRect& originalBounds, bool) {
SkIRect grid;
this->userToGrid(bounds, &grid);
- for (int y = grid.fTop; y <= grid.fBottom; y++) {
- for (int x = grid.fLeft; x <= grid.fRight; x++) {
- fTiles[y * fXTiles + x].push(opIndex);
+ // This is just a loop over y then x. This compiles to a slightly faster and
+ // more compact loop than if we just did fTiles[y * fXTiles + x].push(opIndex).
+ SkTDArray<unsigned>* row = &fTiles[grid.fTop * fXTiles + grid.fLeft];
+ for (int y = 0; y <= grid.fBottom - grid.fTop; y++) {
+ SkTDArray<unsigned>* tile = row;
+ for (int x = 0; x <= grid.fRight - grid.fLeft; x++) {
+ (tile++)->push(opIndex);
}
+ row += fXTiles;
}
}