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; |
} |