RFR: 8295808: GrowableArray should support capacity management
Axel Boldt-Christmas
aboldtch at openjdk.org
Mon Oct 24 08:13:54 UTC 2022
On Sat, 22 Oct 2022 01:38:44 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> Please review this change to GrowableArray to support capacity management.
> Two functions are added to GrowableArray, reserve and shrink_to_fit. Also
> renamed the max_length function to capacity.
>
> Used these new functions in StringDedupTable.
>
> Testing: mach5 tier1-3
LGTM.
Any thoughts of moving `expand_to` and `shrink_to_fit` to a common function, given that they share a lot of logic.
Something like a general resize that
* Allocates if `new_capacity != 0`
* Copy constructs new elements from `0` to `min(old_capacity, new_capacity)`
* Default constructs from `min(old_capacity, new_capacity)` to `new_capacity`
* Destroy old elements from `0` to `old_capacity`
-------------
Marked as reviewed by aboldtch (Committer).
PR: https://git.openjdk.org/jdk/pull/10827
More information about the serviceability-dev
mailing list