RFR: 8314571: GrowableArray should move its old data and not copy it [v2]
Thomas Stuefe
stuefe at openjdk.org
Mon Aug 21 12:42:29 UTC 2023
On Mon, 21 Aug 2023 09:54:07 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
>> Given some `GrowableArray<E>` where `E` is non-copyable with a move constructor will currently fail to compile. This is because `GrowableArray`'s expand and shrink calls the copy constructor. We cast the values to rvalues (akin to `std::move`) to instead call the move constructor if available. If there is no move constructor but there is a copy constructor, then that will be called instead.
>
> Johan Sjölen has updated the pull request incrementally with one additional commit since the last revision:
>
> Use std::move
>From reading the title, I thought this would introduce realloc() - introduce the semantics of grow-in-place for the underlying Allocators. That would be quite useful.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15344#issuecomment-1686253433
More information about the hotspot-dev
mailing list