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

Unified Diff: src/core/SkRecord.cpp

Issue 1081433002: Fix minor undercounting in SkRecord::bytesUsed(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add a comment Created 5 years, 8 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/SkRecord.cpp
diff --git a/src/core/SkRecord.cpp b/src/core/SkRecord.cpp
index c2008a850a730362e5d3b7a810c05b950ceb3eea..349fbf6075e8807aa0c188af28a1d80d5699a278 100644
--- a/src/core/SkRecord.cpp
+++ b/src/core/SkRecord.cpp
@@ -22,7 +22,11 @@ void SkRecord::grow() {
}
size_t SkRecord::bytesUsed() const {
- return fAlloc.approxBytesAllocated() +
- (fReserved - kInlineRecords) * sizeof(Record) +
- sizeof(SkRecord);
+ size_t bytes = fAlloc.approxBytesAllocated() + sizeof(SkRecord);
+ // If fReserved <= kInlineRecords, we've already accounted for fRecords with sizeof(SkRecord).
+ // When we go over that limit, they're allocated on the heap (and the inline space is wasted).
+ if (fReserved > kInlineRecords) {
+ bytes += fReserved * sizeof(Record);
+ }
+ return bytes;
}
« 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