aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/Bytecode.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2010-04-30 15:20:53 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2010-04-30 15:20:53 +0000
commiteb36a2f1aa2dfeedea085f29ba1e1bb76a8da399 (patch)
treebe0ff29c54c05e43bb36ca163afbae9856b1d45d /src/main/javassist/bytecode/Bytecode.java
parent5a38e854c0c4fb5854e7d5475ed132b38beb19f8 (diff)
downloadjavassist-eb36a2f1aa2dfeedea085f29ba1e1bb76a8da399.tar.gz
javassist-eb36a2f1aa2dfeedea085f29ba1e1bb76a8da399.zip
performance tuning
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@541 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/Bytecode.java')
-rw-r--r--src/main/javassist/bytecode/Bytecode.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java
index 64128c53..92fd1f02 100644
--- a/src/main/javassist/bytecode/Bytecode.java
+++ b/src/main/javassist/bytecode/Bytecode.java
@@ -37,7 +37,7 @@ class ByteVector implements Cloneable {
public final byte[] copy() {
byte[] b = new byte[size];
- arraycopy(buffer, b, size);
+ System.arraycopy(buffer, 0, b, 0, size);
return b;
}
@@ -60,6 +60,20 @@ class ByteVector implements Cloneable {
buffer[size - 1] = (byte)code;
}
+ public void add(int b1, int b2) {
+ addGap(2);
+ buffer[size - 2] = (byte)b1;
+ buffer[size - 1] = (byte)b2;
+ }
+
+ public void add(int b1, int b2, int b3, int b4) {
+ addGap(4);
+ buffer[size - 4] = (byte)b1;
+ buffer[size - 3] = (byte)b2;
+ buffer[size - 2] = (byte)b3;
+ buffer[size - 1] = (byte)b4;
+ }
+
public void addGap(int length) {
if (size + length > buffer.length) {
int newSize = size << 1;
@@ -67,17 +81,12 @@ class ByteVector implements Cloneable {
newSize = size + length;
byte[] newBuf = new byte[newSize];
- arraycopy(buffer, newBuf, size);
+ System.arraycopy(buffer, 0, newBuf, 0, size);
buffer = newBuf;
}
size += length;
}
-
- private static void arraycopy(byte[] src, byte[] dest, int size) {
- for (int i = 0; i < size; i++)
- dest[i] = src[i];
- }
}
/**
@@ -376,10 +385,7 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode {
* Appends a 32bit value to the end of the bytecode sequence.
*/
public void add32bit(int value) {
- add(value >> 24);
- add(value >> 16);
- add(value >> 8);
- add(value);
+ add(value >> 24, value >> 16, value >> 8, value);
}
/**
@@ -441,8 +447,7 @@ public class Bytecode extends ByteVector implements Cloneable, Opcode {
* It never changes the current stack depth.
*/
public void addIndex(int index) {
- add(index >> 8);
- add(index);
+ add(index >> 8, index);
}
/**