diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java index b246a1e..695d659 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java @@ -15,12 +15,10 @@ */ package org.jetbrains.java.decompiler.struct.attr; -import com.intellij.openapi.util.Pair; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.IOException; -import java.util.*; /** * u2 line_number_table_length; @@ -31,37 +29,33 @@ import java.util.*; * Created by Egor on 05.10.2014. */ public class StructLineNumberTableAttribute extends StructGeneralAttribute { - private List<Pair<Integer, Integer>> myLineInfo = Collections.emptyList(); + private int[] myLineInfo = new int[0]; @Override public void initContent(ConstantPool pool) throws IOException { DataInputFullStream data = stream(); - int len = data.readUnsignedShort(); + int len = data.readUnsignedShort() * 2; if (len > 0) { - myLineInfo = new ArrayList<Pair<Integer, Integer>>(len); - for (int i = 0; i < len; i++) { - int startPC = data.readUnsignedShort(); - int lineNumber = data.readUnsignedShort(); - myLineInfo.add(Pair.create(startPC, lineNumber)); + myLineInfo = new int[len]; + for (int i = 0; i < len; i += 2) { + myLineInfo[i] = data.readUnsignedShort(); + myLineInfo[i + 1] = data.readUnsignedShort(); } } - else { - myLineInfo = Collections.emptyList(); + else if (myLineInfo.length > 0) { + myLineInfo = new int[0]; } } public int getFirstLine() { - if (!myLineInfo.isEmpty()) { - return myLineInfo.get(0).getSecond(); - } - return -1; + return myLineInfo.length > 0 ? myLineInfo[1] : -1; } public int findLineNumber(int pc) { - for (Pair<Integer, Integer> pair : myLineInfo) { - if (pc >= pair.getFirst()) { - return pair.getSecond(); + for (int i = 0; i < myLineInfo.length; i += 2) { + if (pc >= myLineInfo[i]) { + return myLineInfo[i + 1]; } } return -1; |