array clone() vs Arrays.copyOf()
forax at univ-mlv.fr
Wed Apr 27 19:07:03 UTC 2011
On 04/27/2011 08:04 PM, Lance Andersen - Oracle wrote:
> Hi David, Stuart
> On Apr 26, 2011, at 8:34 PM, David Holmes wrote:
>> Hi Stuart,
>> Actually my comments more a response to Remi's assertion that clone should have been used instead, without giving any technical rationale as to why clone would be better, and so much better that it warranted Lance changing the code.
>> Personally I think we should be steering people to Arrays.copyOf for all their array copying needs. clone() is effectively legacy code. It may have a small performance benefit though ultimately both methods are intrinisified by the same C2 code so I don't believe the gain would be much, and likely only with smaller arrays.
>> BTW I think Lance received communication from others over the use of copyOf versus clone, I never made any additional comments on the relative merits.
> Yes, I did receive additional input WRT using copyOf. I am going to stick with copyOf and I appreciate Remi's time and input (as I really do not want to change BatchUpdateException again ;-) ).
> Thank you for input.
> My Best,
As I said, I'm not against Arrays.copyOf,
for me it's like comparing for() and while().
More information about the core-libs-dev