avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@apache.org
Subject [avro] branch master updated: AVRO-2654: Use JDK Arrays.copyOf (#743)
Date Thu, 26 Dec 2019 20:31:54 GMT
This is an automated email from the ASF dual-hosted git repository.

fokko 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 ff5c4d6  AVRO-2654: Use JDK Arrays.copyOf (#743)
ff5c4d6 is described below

commit ff5c4d6db9af3edd915a2176a627d51eb3478da3
Author: belugabehr <12578579+belugabehr@users.noreply.github.com>
AuthorDate: Thu Dec 26 15:31:46 2019 -0500

    AVRO-2654: Use JDK Arrays.copyOf (#743)
---
 .../src/main/java/org/apache/avro/data/RecordBuilderBase.java     | 3 +--
 lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java       | 8 +++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java b/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
index 91276ef..431733c 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/data/RecordBuilderBase.java
@@ -73,8 +73,7 @@ public abstract class RecordBuilderBase<T extends IndexedRecord> implements
Reco
     this.schema = other.schema;
     this.data = data;
     fields = schema.getFields().toArray(EMPTY_FIELDS);
-    fieldSetFlags = new boolean[other.fieldSetFlags.length];
-    System.arraycopy(other.fieldSetFlags, 0, fieldSetFlags, 0, fieldSetFlags.length);
+    fieldSetFlags = Arrays.copyOf(other.fieldSetFlags, other.fieldSetFlags.length);
   }
 
   /**
diff --git a/lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java b/lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java
index e0ec85c..dd1c801 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/util/Utf8.java
@@ -18,6 +18,7 @@
 package org.apache.avro.util;
 
 import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
 
 import org.apache.avro.AvroRuntimeException;
 import org.apache.avro.io.BinaryData;
@@ -61,8 +62,7 @@ public class Utf8 implements Comparable<Utf8>, CharSequence {
 
   public Utf8(Utf8 other) {
     this.length = other.length;
-    this.bytes = new byte[other.length];
-    System.arraycopy(other.bytes, 0, this.bytes, 0, this.length);
+    this.bytes = Arrays.copyOf(other.bytes, other.length);
     this.string = other.string;
   }
 
@@ -113,9 +113,7 @@ public class Utf8 implements Comparable<Utf8>, CharSequence {
       throw new AvroRuntimeException("String length " + newLength + " exceeds maximum allowed");
     }
     if (this.bytes.length < newLength) {
-      byte[] newBytes = new byte[newLength];
-      System.arraycopy(bytes, 0, newBytes, 0, this.length);
-      this.bytes = newBytes;
+      this.bytes = Arrays.copyOf(this.bytes, newLength);
     }
     this.length = newLength;
     this.string = null;


Mime
View raw message