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 612272e Replace manual copy of array contents with System.arraycopy(). (#246) 612272e is described below commit 612272e2d52e87f50f988d40e61a36f2ea812052 Author: Arturo Bernal <arturobern...@gmail.com> AuthorDate: Sun Feb 13 17:00:21 2022 +0100 Replace manual copy of array contents with System.arraycopy(). (#246) --- .../commons/compress/harmony/pack200/AttributeDefinitionBands.java | 4 +--- .../java/org/apache/commons/compress/harmony/unpack200/Segment.java | 4 +--- .../compress/harmony/unpack200/bytecode/ExceptionsAttribute.java | 4 +--- .../compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java | 4 +--- .../compress/harmony/unpack200/bytecode/forms/TableSwitchForm.java | 4 +--- 5 files changed, 5 insertions(+), 15 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 bb4b022..a36b52c 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 @@ -166,9 +166,7 @@ public class AttributeDefinitionBands extends BandSet { private int[] addHighIndices(final int[] availableIndices) { final int[] temp = new int[availableIndices.length + 32]; - for (int i = 0; i < availableIndices.length; i++) { - temp[i] = availableIndices[i]; - } + System.arraycopy(availableIndices, 0, temp, 0, availableIndices.length); 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/unpack200/Segment.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java index e1a5028..242163f 100644 --- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java +++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java @@ -270,9 +270,7 @@ public class Segment { // existing classFile attributes. final Attribute[] originalAttrs = classFile.attributes; final Attribute[] newAttrs = new Attribute[originalAttrs.length + 1]; - for (int index = 0; index < originalAttrs.length; index++) { - newAttrs[index] = originalAttrs[index]; - } + System.arraycopy(originalAttrs, 0, newAttrs, 0, originalAttrs.length); newAttrs[newAttrs.length - 1] = innerClassesAttribute; classFile.attributes = newAttrs; cp.addWithNestedEntries(innerClassesAttribute); diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java index 68486ff..400df03 100644 --- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java +++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/ExceptionsAttribute.java @@ -74,9 +74,7 @@ public class ExceptionsAttribute extends Attribute { @Override protected ClassFileEntry[] getNestedClassFileEntries() { final ClassFileEntry[] result = new ClassFileEntry[exceptions.length + 1]; - for (int i = 0; i < exceptions.length; i++) { - result[i] = exceptions[i]; - } + System.arraycopy(exceptions, 0, result, 0, exceptions.length); result[exceptions.length] = getAttributeName(); return result; } diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java index 2fe1006..7f021fd 100644 --- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java +++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/LookupSwitchForm.java @@ -49,9 +49,7 @@ public class LookupSwitchForm extends SwitchForm { final int[] labelsArray = new int[case_count + 1]; labelsArray[0] = default_pc; - for (int index = 1; index < case_count + 1; index++) { - labelsArray[index] = case_pcs[index - 1]; - } + System.arraycopy(case_pcs, 0, labelsArray, 1, case_count + 1 - 1); byteCode.setByteCodeTargets(labelsArray); // All this gets dumped into the rewrite bytes of the diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/TableSwitchForm.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/TableSwitchForm.java index 11e5425..28e3d18 100644 --- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/TableSwitchForm.java +++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/forms/TableSwitchForm.java @@ -48,9 +48,7 @@ public class TableSwitchForm extends SwitchForm { final int[] labelsArray = new int[case_count + 1]; labelsArray[0] = default_pc; - for (int index = 1; index < case_count + 1; index++) { - labelsArray[index] = case_pcs[index - 1]; - } + System.arraycopy(case_pcs, 0, labelsArray, 1, case_count + 1 - 1); byteCode.setByteCodeTargets(labelsArray); final int lowValue = case_value;