aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShigeru Chiba <chibash@users.noreply.github.com>2022-05-13 02:41:05 +0900
committerGitHub <noreply@github.com>2022-05-13 02:41:05 +0900
commitdf3f4b7641d39558465a17514bffce657f2a27da (patch)
treee8113e4135dddfa7048e92dde565e5718e9ed211 /src
parentc00688b472de13a57930694b6f5b1238a7845d75 (diff)
parentaeee909ea7a5c12c591301e346a1da12c6e356f6 (diff)
downloadjavassist-df3f4b7641d39558465a17514bffce657f2a27da.tar.gz
javassist-df3f4b7641d39558465a17514bffce657f2a27da.zip
Merge pull request #383 from tim-hoffman/PR_ArrayCopyPerformance
Replace array copy loops with System.arraycopy
Diffstat (limited to 'src')
-rw-r--r--src/main/javassist/bytecode/StackMapTable.java12
-rw-r--r--src/main/javassist/bytecode/stackmap/MapMaker.java3
2 files changed, 10 insertions, 5 deletions
diff --git a/src/main/javassist/bytecode/StackMapTable.java b/src/main/javassist/bytecode/StackMapTable.java
index 62a6aca0..4fed2010 100644
--- a/src/main/javassist/bytecode/StackMapTable.java
+++ b/src/main/javassist/bytecode/StackMapTable.java
@@ -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;
}
diff --git a/src/main/javassist/bytecode/stackmap/MapMaker.java b/src/main/javassist/bytecode/stackmap/MapMaker.java
index bd79377f..d016a3be 100644
--- a/src/main/javassist/bytecode/stackmap/MapMaker.java
+++ b/src/main/javassist/bytecode/stackmap/MapMaker.java
@@ -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) {