Since List<AVM2Instruction> code is frequently accessed by position, it's better to use an ArrayList instead of a LinkedList. Introduced method compact() to reduce memory usage.

This commit is contained in:
Paolo Cancedda
2012-01-03 15:06:47 +01:00
parent ea14fb2d3d
commit c1f1ad6dcd
2 changed files with 7 additions and 1 deletions
@@ -60,7 +60,7 @@ import java.util.regex.Pattern;
public class AVM2Code {
public List<AVM2Instruction> code = new LinkedList<AVM2Instruction>();
public ArrayList<AVM2Instruction> code = new ArrayList<AVM2Instruction>();
public static boolean DEBUG_REWRITE=false;
public static final int OPT_U30 = 0x100;
public static final int OPT_U8 = 0x200;
@@ -705,6 +705,10 @@ public class AVM2Code {
}
}
public void compact() {
code.trimToSize();
}
public byte[] getBytes() {
return getBytes(null);
}
@@ -287,6 +287,8 @@ public class ASM3Parser {
}
} while (symb.type != ParsedSymbol.TYPE_EOF);
code.compact();
for (OffsetItem oi : offsetItems) {
for (LabelItem li : labelItems) {
if (oi.label.equals(li.label)) {