Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-20 Thread Stian Soiland-Reyes
On Fri, 16 Feb 2018 20:11:11 +0100, Gilles wrote: > Bottom-line: Don't use clone except to copy arrays. > So I'd rephrase my comment on the commit: let "clone()" in place > but with the comment that it's the only acceptable use of it. OK, I've added such comments :) (It was also used for copying

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-16 Thread Gilles
On Fri, 16 Feb 2018 08:33:46 -0800, Chas Honton wrote: Read Bloch. Don’t optimize until you have proven that this bit of code is causing a significant performance hit. arrayCopy can and is inlined by jit https://www.artima.com/intv/bloch13.html Bottom-line: Don't use clone except to copy arra

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-16 Thread Chas Honton
Read Bloch. Don’t optimize until you have proven that this bit of code is causing a significant performance hit. arrayCopy can and is inlined by jit. Chas > On Feb 16, 2018, at 5:53 AM, Stian Soiland-Reyes wrote: > > String is still a type of Object (requiring GC handling of reference > cou

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-16 Thread Gilles
On Fri, 16 Feb 2018 13:53:28 +, Stian Soiland-Reyes wrote: String is still a type of Object (requiring GC handling of reference counters), as you can do Object[] o = stringArray.clone(); without casting. (other way not so) https://www.javaspecialists.eu/archive/Issue124.html says there is h

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-16 Thread Stian Soiland-Reyes
String is still a type of Object (requiring GC handling of reference counters), as you can do Object[] o = stringArray.clone(); without casting. (other way not so) https://www.javaspecialists.eu/archive/Issue124.html says there is hardly any difference, so I don't think we need to fight this one

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-16 Thread sebb
On 16 February 2018 at 10:01, Stian Soiland-Reyes wrote: > I agree in general for .clone() on objects - and I'm trying to move > away from using .clone() in that Commons RDF fluent mutable/immutable > builder (See COMMONSRDF-49). > > But this is an Object[] - a native type. Huh? The code says St

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-16 Thread Stian Soiland-Reyes
I agree in general for .clone() on objects - and I'm trying to move away from using .clone() in that Commons RDF fluent mutable/immutable builder (See COMMONSRDF-49). But this is an Object[] - a native type. I must admit I am not sure what is really the preferred way - I thought .clone() is best

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-13 Thread Gilles
On Tue, 13 Feb 2018 18:40:13 +, sebb wrote: On 13 February 2018 at 09:31, Gilles wrote: On Tue, 13 Feb 2018 00:16:13 + (UTC), st...@apache.org wrote: Repository: commons-csv Updated Branches: refs/heads/CSV-216 637ad2d7a -> f66a83901 CSV-216: Avoid Arrays.copyOf() Why? Agreed

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-13 Thread sebb
On 13 February 2018 at 09:31, Gilles wrote: > On Tue, 13 Feb 2018 00:16:13 + (UTC), st...@apache.org wrote: >> >> Repository: commons-csv >> Updated Branches: >> refs/heads/CSV-216 637ad2d7a -> f66a83901 >> >> >> CSV-216: Avoid Arrays.copyOf() > > > Why? Agreed >> as .clone() will do > > >

Re: commons-csv git commit: CSV-216: Avoid Arrays.copyOf()

2018-02-13 Thread Gilles
On Tue, 13 Feb 2018 00:16:13 + (UTC), st...@apache.org wrote: Repository: commons-csv Updated Branches: refs/heads/CSV-216 637ad2d7a -> f66a83901 CSV-216: Avoid Arrays.copyOf() Why? as .clone() will do We should rather avoid using "clone()". Gilles -- at least until someone tries