Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30750

Re: Recommended way to make shallow copy of array

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From v_borchert@despammed.com (Volker Borchert)
Newsgroups comp.lang.java.programmer
Subject Re: Recommended way to make shallow copy of array
Date 19 Jan 2015 20:15:22 GMT
Organization Private site at Eddersheim, Germany
Lines 29
Distribution world
Message-ID <m9jokq$3ih$1@Gaia.teknon.de> (permalink)
References <m93su6$n1u$1@Gaia.teknon.de> <m944pq$58h$1@news.albasani.net>
X-Trace individual.net fmfnNgZSyOwi8AhUwpXy+gxgB9bv18bFP2GERNyDqc94LfbAOO
Cancel-Lock sha1:UOsWSR/taPR+ojrFCZTbn92HCl8=
Xref csiph.com comp.lang.java.programmer:30750

Show key headers only | View raw


Sebastian wrote:

> - use System.arraycopy (useful in particular when copying parts of an 
> array)

That's what Array.copyOf() and Arrays.copyOfRange() do.

> The for-loop, copyOf and System.arraycopy styles clearly have 
> independent storage, a clone of a one-dimensional array has independent 
> storage, but the clone of a multi-dimensional array does not.
> 
> System.arraycopy seems to have slightly better performance. 
> Arrays.copyOf is easiest to use with dynamic typing.

The question is, what happens when the JIT kicks in and starts
inlining and/or intrinsifying...

> Differences between the various methods are small, however, and might be 
> regarded a micro-optimization.

OK that should do, at least for now and until proven wrong.

Thanks


-- 

"I'm a doctor, not a mechanic." Dr Leonard McCoy <mccoy@ncc1701.starfleet.fed>
"I'm a mechanic, not a doctor." Volker Borchert  <v_borchert@despammed.com>

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Recommended way to make shallow copy of array v_borchert@despammed.com (Volker Borchert) - 2015-01-13 19:50 +0000
  Re: Recommended way to make shallow copy of array Joerg Meier <joergmmeier@arcor.de> - 2015-01-13 22:40 +0100
    Re: Recommended way to make shallow copy of array Joerg Meier <joergmmeier@arcor.de> - 2015-01-13 22:44 +0100
  Re: Recommended way to make shallow copy of array Sebastian <news@seyweiler.dyndns.org> - 2015-01-13 23:04 +0100
    Re: Recommended way to make shallow copy of array Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-01-13 18:00 -0500
    Re: Recommended way to make shallow copy of array v_borchert@despammed.com (Volker Borchert) - 2015-01-19 20:15 +0000

csiph-web