This page is no longer maintained — Please continue to the home page at

Scaling problems for Array.slice on large arrays

1 reply
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
I've been using Array[Byte] for storing images and using Array.slice to clone them, but noticed apperant delays in my program whenever I used it.

Could it be an idea to add System.arraycopy as an optimization for the JVM?
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Scaling problems for Array.slice on large arrays

Array.slice gives you a projection (i.e forwareder to old array)
rather than a new array. This can affect algorithmic complexity. If
you want a new array, use Array.copy, with parameters as in

Btw, I believe this design of slice was a mistake. In 2.8, slice will
give you a new array, to get a projection, you'll have to write


- Martin

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland