Chromium Code Reviews| Index: courgette/memory_allocator.h |
| diff --git a/courgette/memory_allocator.h b/courgette/memory_allocator.h |
| index 5386dad0d7d9ead4b26bd66d083eefb9f2ceb0d1..ada7f40b8438b42c14d4de0c952d552f727677d9 100644 |
| --- a/courgette/memory_allocator.h |
| +++ b/courgette/memory_allocator.h |
| @@ -333,6 +333,12 @@ class NoThrowBuffer { |
| if (size < kStartSize) |
| size = kStartSize; |
| + // Use a size 1% higher than requested. In practice, this makes Courgette as |
| + // much as 5x faster on typical Chrome update payloads as a lot of future |
| + // reserve() calls will become no-ops instead of costly resizes that copy |
| + // all the data. Note that doing this here instead of outside the function |
| + // is more efficient, since it's after the no-op early return checks above. |
| + size *= 1.01; |
|
gab
2014/09/12 04:12:19
This will have no impact on reserves below 100, sh
gab
2014/09/12 04:16:06
Oops s/multiple of 2/power of 2/ of course.
|
| T* new_buffer = alloc_.allocate(size); |
| if (!new_buffer) { |
| clear(); |