You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ie...@apache.org on 2019/01/29 09:37:16 UTC
[avro] branch master updated: AVRO-2310: GenericData Array Add Use
JDK Copy Facilities
This is an automated email from the ASF dual-hosted git repository.
iemejia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new 0de8055 AVRO-2310: GenericData Array Add Use JDK Copy Facilities
0de8055 is described below
commit 0de805575f41c2d7deff9fcbe408e51606f88269
Author: Beluga Behr <da...@gmail.com>
AuthorDate: Mon Jan 28 17:56:45 2019 -0500
AVRO-2310: GenericData Array Add Use JDK Copy Facilities
---
.../avro/src/main/java/org/apache/avro/generic/GenericData.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
index 26b0872..4d95ae5 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
@@ -301,9 +301,9 @@ public class GenericData {
throw new IndexOutOfBoundsException("Index " + location + " out of bounds.");
}
if (size == elements.length) {
- Object[] newElements = new Object[(size * 3)/2 + 1];
- System.arraycopy(elements, 0, newElements, 0, size);
- elements = newElements;
+ // Increase size by 1.5x + 1
+ final int newSize = size + (size >> 1) + 1;
+ elements = Arrays.copyOf(elements, newSize);
}
System.arraycopy(elements, location, elements, location + 1, size - location);
elements[location] = o;