From 295706f9f8997604201fa004e79c2654144ccc99 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 30 Jun 2011 12:42:17 +0000 Subject: [PATCH] LUCENE-3239: remove use of slow Arrays.copyOf git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1141510 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/util/UnsafeByteArrayOutputStream.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/facet/src/java/org/apache/lucene/util/UnsafeByteArrayOutputStream.java b/modules/facet/src/java/org/apache/lucene/util/UnsafeByteArrayOutputStream.java index 5345e433a5d..cc62405793c 100644 --- a/modules/facet/src/java/org/apache/lucene/util/UnsafeByteArrayOutputStream.java +++ b/modules/facet/src/java/org/apache/lucene/util/UnsafeByteArrayOutputStream.java @@ -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 extends OutputStream { } 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; } /**