This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 9045a2d1 Use Arrays.copyOf() and copyOfRange()
9045a2d1 is described below
commit 9045a2d1e687492f6f6e28e378a60f43f90a8e48
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Dec 28 19:35:40 2022 -0500
Use Arrays.copyOf() and copyOfRange()
---
.../commons/compress/harmony/pack200/AttributeDefinitionBands.java | 4 ++--
.../org/apache/commons/compress/harmony/pack200/PopulationCodec.java | 4 ++--
.../harmony/unpack200/bytecode/LocalVariableTableAttribute.java | 4 ++--
.../harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java | 4 ++--
.../compress/harmony/unpack200/bytecode/forms/ByteCodeForm.java | 5 ++---
5 files changed, 10 insertions(+), 11 deletions(-)
diff --git
a/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
b/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
index 060c075a..300fe32b 100644
---
a/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
+++
b/src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java
@@ -19,6 +19,7 @@ package org.apache.commons.compress.harmony.pack200;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -146,8 +147,7 @@ public class AttributeDefinitionBands extends BandSet {
}
private int[] addHighIndices(final int[] availableIndices) {
- final int[] temp = new int[availableIndices.length + 32];
- System.arraycopy(availableIndices, 0, temp, 0,
availableIndices.length);
+ final int[] temp = Arrays.copyOf(availableIndices,
availableIndices.length + 32);
int j = 32;
for (int i = availableIndices.length; i < temp.length; i++) {
temp[i] = j;
diff --git
a/src/main/java/org/apache/commons/compress/harmony/pack200/PopulationCodec.java
b/src/main/java/org/apache/commons/compress/harmony/pack200/PopulationCodec.java
index 7b214bfc..491eca5d 100644
---
a/src/main/java/org/apache/commons/compress/harmony/pack200/PopulationCodec.java
+++
b/src/main/java/org/apache/commons/compress/harmony/pack200/PopulationCodec.java
@@ -18,6 +18,7 @@ package org.apache.commons.compress.harmony.pack200;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
/**
* A PopulationCodec is a Codec that is well suited to encoding data that
shows statistical or repetitive patterns,
@@ -132,8 +133,7 @@ public class PopulationCodec extends Codec {
}
public byte[] encode(final int[] favoured, final int[] tokens, final int[]
unfavoured) throws Pack200Exception {
- final int[] favoured2 = new int[favoured.length + 1];
- System.arraycopy(favoured, 0, favoured2, 0, favoured.length);
+ final int[] favoured2 = Arrays.copyOf(favoured, favoured.length + 1);
favoured2[favoured2.length - 1] = favoured[favoured.length - 1]; //
repeat last value;
final byte[] favouredEncoded = favouredCodec.encode(favoured2);
final byte[] tokensEncoded = tokenCodec.encode(tokens);
diff --git
a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
index 719716a7..42651082 100644
---
a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
+++
b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTableAttribute.java
@@ -19,6 +19,7 @@ package
org.apache.commons.compress.harmony.unpack200.bytecode;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.apache.commons.compress.harmony.pack200.Pack200Exception;
@@ -84,8 +85,7 @@ public class LocalVariableTableAttribute extends
BCIRenumberedAttribute {
public void renumber(final List<Integer> byteCodeOffsets) throws
Pack200Exception {
// Remember the unrenumbered start_pcs, since that's used later
// to calculate end position.
- final int[] unrenumbered_start_pcs = new int[start_pcs.length];
- System.arraycopy(start_pcs, 0, unrenumbered_start_pcs, 0,
start_pcs.length);
+ final int[] unrenumbered_start_pcs = Arrays.copyOf(start_pcs,
start_pcs.length);
// Next renumber start_pcs in place
super.renumber(byteCodeOffsets);
diff --git
a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
index 937daebb..81da4920 100644
---
a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
+++
b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/LocalVariableTypeTableAttribute.java
@@ -19,6 +19,7 @@ package
org.apache.commons.compress.harmony.unpack200.bytecode;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.apache.commons.compress.harmony.pack200.Pack200Exception;
@@ -84,8 +85,7 @@ public class LocalVariableTypeTableAttribute extends
BCIRenumberedAttribute {
public void renumber(final List<Integer> byteCodeOffsets) throws
Pack200Exception {
// Remember the unrenumbered start_pcs, since that's used later
// to calculate end position.
- final int[] unrenumbered_start_pcs = new int[start_pcs.length];
- System.arraycopy(start_pcs, 0, unrenumbered_start_pcs, 0,
start_pcs.length);
+ final int[] unrenumbered_start_pcs = Arrays.copyOf(start_pcs,
start_pcs.length);
// Next renumber start_pcs in place
super.renumber(byteCodeOffsets);
diff --git
a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/ByteCodeForm.java
b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/ByteCodeForm.java
index 83810eec..1b594df0 100644
---
a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/ByteCodeForm.java
+++
b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/ByteCodeForm.java
@@ -16,6 +16,7 @@
*/
package org.apache.commons.compress.harmony.unpack200.bytecode.forms;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -394,9 +395,7 @@ public abstract class ByteCodeForm {
}
public int[] getRewriteCopy() {
- final int[] result = new int[rewrite.length];
- System.arraycopy(rewrite, 0, result, 0, rewrite.length);
- return result;
+ return Arrays.copyOf(rewrite, rewrite.length);
}
/**