Index: src/core/SkTileGrid.cpp |
diff --git a/src/core/SkTileGrid.cpp b/src/core/SkTileGrid.cpp |
index fd00253097ed87d578309d268254b4eccf50a7ef..10782c4d6d658e33541b960cdda27c97edb2499b 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; |
} |
} |