Browse Source

Merge pull request #383 from tim-hoffman/PR_ArrayCopyPerformance

Replace array copy loops with System.arraycopy
tags/rel_3_29_0_ga
Shigeru Chiba 1 year ago
parent
commit
df3f4b7641
No account linked to committer's email address

+ 9
- 3
src/main/javassist/bytecode/StackMapTable.java View File

@@ -912,9 +912,15 @@ public class StackMapTable extends AttributeInfo {
static byte[] insertGap(byte[] info, int where, int gap) {
int len = info.length;
byte[] newinfo = new byte[len + gap];
for (int i = 0; i < len; i++)
newinfo[i + (i < where ? 0 : gap)] = info[i];

if (where <= 0) {
System.arraycopy(info, 0, newinfo, gap, len);
} else if (where >= len) {
System.arraycopy(info, 0, newinfo, 0, len);
} else {
assert (where > 0 && where < len);
System.arraycopy(info, 0, newinfo, 0, where);
System.arraycopy(info, where, newinfo, where + gap, len - where);
}
return newinfo;
}


+ 1
- 2
src/main/javassist/bytecode/stackmap/MapMaker.java View File

@@ -309,8 +309,7 @@ public class MapMaker extends Tracer {
}

protected static void copyTypeData(int n, TypeData[] srcTypes, TypeData[] destTypes) {
for (int i = 0; i < n; i++)
destTypes[i] = srcTypes[i];
System.arraycopy(srcTypes, 0, destTypes, 0, n);
}

private static TypeData validateTypeData(TypeData[] data, int length, int index) {

Loading…
Cancel
Save