Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1087)

Unified Diff: src/core/SkTileGrid.cpp

Issue 658913002: Tweak out SkTileGrid::insert() loop. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: merge Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698