Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace array copy loops with System.arraycopy #383

Merged
merged 1 commit into from May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/javassist/bytecode/StackMapTable.java
Expand Up @@ -912,9 +912,15 @@ else if (offsetDelta < 64 && current != entry) {
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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/javassist/bytecode/stackmap/MapMaker.java
Expand Up @@ -309,8 +309,7 @@ protected static int recordTypeData(int n, TypeData[] srcTypes, TypeData[] destT
}

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) {
Expand Down