Hi Robert,

you reverted a use of Arrays.copyOf() on native types which is *exactly* 
implemented like this in Arrays.java code!

The slow ones are <T> T[] copyOf(T[] array, int newlen)

(because they use reflection).

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de


> -----Original Message-----
> From: rm...@apache.org [mailto:rm...@apache.org]
> Sent: Thursday, June 30, 2011 2:42 PM
> To: comm...@lucene.apache.org
> Subject: svn commit: r1141510 -
> /lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/Unsafe
> ByteArrayOutputStream.java
> 
> Author: rmuir
> Date: Thu Jun 30 12:42:17 2011
> New Revision: 1141510
> 
> URL: http://svn.apache.org/viewvc?rev=1141510&view=rev
> Log:
> LUCENE-3239: remove use of slow Arrays.copyOf
> 
> Modified:
> 
> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/UnsafeB
> yteArrayOutputStream.java
> 
> Modified:
> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/UnsafeB
> yteArrayOutputStream.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/trunk/modules/facet/src/java/or
> g/apache/lucene/util/UnsafeByteArrayOutputStream.java?rev=1141510&r1
> =1141509&r2=1141510&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/UnsafeB
> yteArrayOutputStream.java (original)
> +++
> lucene/dev/trunk/modules/facet/src/java/org/apache/lucene/util/Unsaf
> +++ eByteArrayOutputStream.java Thu Jun 30 12:42:17 2011
> @@ -2,7 +2,6 @@ package org.apache.lucene.util;
> 
>  import java.io.IOException;
>  import java.io.OutputStream;
> -import java.util.Arrays;
> 
>  /**
>   * Licensed to the Apache Software Foundation (ASF) under one or more
> @@ -72,7 +71,11 @@ public class UnsafeByteArrayOutputStream
>    }
> 
>    private void grow(int newLength) {
> -    buffer = Arrays.copyOf(buffer, newLength);
> +    // It actually should be: (Java 1.7, when its intrinsic on all machines)
> +    // buffer = Arrays.copyOf(buffer, newLength);
> +    byte[] newBuffer = new byte[newLength];
> +    System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
> +    buffer = newBuffer;
>    }
> 
>    /**
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to