JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods

Vitaly Davidovich vitalyd at gmail.com
Mon Jan 30 21:17:15 UTC 2012


I would also expect clone to run a bit faster than copy constructor, if for
nothing else than clone not executing any constructor; this perf diff would
probably be more noticeable in interpreter as compiler may inline
constructor.  In addition, I'd also think that clone can basically be
equivalent to memcpy which should be faster.

Sent from my phone
On Jan 30, 2012 4:08 PM, "Ulf Zibis" <Ulf.Zibis at gmx.de> wrote:

> Am 30.01.2012 14:28, schrieb Tom Hawtin:
>
>> On 30/01/2012 13:16, Ulf Zibis wrote:
>>
>>> Isn't cloning faster than normal instantiation?
>>> I can imagine, that behind the scenes cloning mainly only needs to
>>> duplicate the binary footprint of an object.
>>>
>>
>> I don't see a good reason why it should be (equally, I've not tried
>> benchmarking).
>>
>> For the immediate fields of an object, (partial) bitwise copying "by
>> hand" should be of comparable performance to a bitwise clone. For copying
>> the referenced objects, there is no benefit for the clone.
>>
>
> Is there anybody, who knows this exactly, e.g. in reference to Hotspot
> runtime?
>
> -Ulf
>
>



More information about the core-libs-dev mailing list