diff options
author | 2012-08-14 17:19:08 +0000 | |
---|---|---|
committer | 2012-08-14 17:19:08 +0000 | |
commit | 137209f9f4b6ee08ca59a135909185cb0caf6d91 (patch) | |
tree | 3079b7cbebbc78632e396a91c52d5a85b3a02e37 | |
parent | 686e68019374dca3692cac6d5f8d94515e53d6c8 (diff) |
Make SkTArray consider only the new count and reserve when determining how much to alloc
Review URL: http://codereview.appspot.com/6459084
git-svn-id: http://skia.googlecode.com/svn/trunk@5084 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkTArray.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h index 577e8600b8..01fc1421b3 100644 --- a/include/core/SkTArray.h +++ b/include/core/SkTArray.h @@ -331,13 +331,11 @@ private: int newCount = fCount + delta; int newAllocCount = fAllocCount; - if (newCount > fAllocCount) { - newAllocCount = SkMax32(newCount + ((newCount + 1) >> 1), - fReserveCount); - } else if (newCount < fAllocCount / 3) { - newAllocCount = SkMax32(fAllocCount / 2, fReserveCount); + if (newCount > fAllocCount || newCount < (fAllocCount / 3)) { + // whether we're growing or shrinking, we leave at least 50% extra space for future + // growth (clamped to the reserve count). + newAllocCount = SkMax32(newCount + ((newCount + 1) >> 1), fReserveCount); } - if (newAllocCount != fAllocCount) { fAllocCount = newAllocCount; |