Skip to content
Permalink
Browse files
Replace manual copy of array contents with System.arraycopy(). (#246)
  • Loading branch information
arturobernalg committed Feb 13, 2022
1 parent 49be5a7 commit 612272e2d52e87f50f988d40e61a36f2ea812052
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 15 deletions.
@@ -166,9 +166,7 @@ private void addSyntheticDefinitions() {

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;
@@ -270,9 +270,7 @@ private ClassFile buildClassFile(final int classNum) {
// 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);
@@ -74,9 +74,7 @@ protected int getLength() {
@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;
}
@@ -49,9 +49,7 @@ public void setByteCodeOperands(final ByteCode byteCode, final OperandManager op

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
@@ -48,9 +48,7 @@ public void setByteCodeOperands(final ByteCode byteCode, final OperandManager op

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;

0 comments on commit 612272e

Please sign in to comment.