-
Tobias Tebbi authored
We currently grow the backing store to (old_capacity*1.5)+16 if we exceed capacity, but shrink the capacity to the current length when 2*length <= capacity. For short arrays (up to length 32), this can lead to a copy on every operation when using push/pop or push/shift. Example: Array of length 32, capacity 32 push Array grown to length 33, capacity 32*1.5+16 = 64 pop Array trimmed to length 32, capacity 32 because 2*32 <= 64 ... This CL leaves additional slag space when calling pop and restricts the trimming to backing stores with at least 16 elements to prevent excessive re-trimming on short arrays. Bug: Change-Id: I9dd13e5e2550c7ac819294c8e29f04c8855e02a4 Reviewed-on: https://chromium-review.googlesource.com/502911 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#45324}
cd33ec55