decompiler: minor optimization - less calculateLines calls

master
Egor.Ushakov 10 years ago
parent 1a183952b4
commit 9b97ae55f8
  1. 9
      src/org/jetbrains/java/decompiler/main/ClassWriter.java

@ -161,7 +161,7 @@ public class ClassWriter {
ClassNode outerNode = (ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE); ClassNode outerNode = (ClassNode)DecompilerContext.getProperty(DecompilerContext.CURRENT_CLASS_NODE);
DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, node); DecompilerContext.setProperty(DecompilerContext.CURRENT_CLASS_NODE, node);
final int startLine = tracer != null ? tracer.getCurrentSourceLine() : 0; int startLine = tracer != null ? tracer.getCurrentSourceLine() : 0;
BytecodeMappingTracer dummy_tracer = new BytecodeMappingTracer(); BytecodeMappingTracer dummy_tracer = new BytecodeMappingTracer();
try { try {
@ -216,7 +216,7 @@ public class ClassWriter {
} }
// FIXME: fields don't matter at the moment // FIXME: fields don't matter at the moment
//startLine = buffer.countLines(start_class_def); startLine += buffer.countLines(start_class_def);
// methods // methods
for (StructMethod mt : cl.getMethods()) { for (StructMethod mt : cl.getMethods()) {
@ -228,14 +228,15 @@ public class ClassWriter {
int position = buffer.length(); int position = buffer.length();
if (hasContent) { if (hasContent) {
buffer.appendLineSeparator(); buffer.appendLineSeparator();
startLine++;
} }
BytecodeMappingTracer method_tracer = new BytecodeMappingTracer(buffer.countLines() + startLine); BytecodeMappingTracer method_tracer = new BytecodeMappingTracer(startLine);
boolean methodSkipped = !methodToJava(node, mt, buffer, indent + 1, method_tracer); boolean methodSkipped = !methodToJava(node, mt, buffer, indent + 1, method_tracer);
if (!methodSkipped) { if (!methodSkipped) {
hasContent = true; hasContent = true;
DecompilerContext.getBytecodeSourceMapper().addTracer(cl.qualifiedName, DecompilerContext.getBytecodeSourceMapper().addTracer(cl.qualifiedName,
InterpreterUtil.makeUniqueKey(mt.getName(), mt.getDescriptor()), method_tracer); InterpreterUtil.makeUniqueKey(mt.getName(), mt.getDescriptor()), method_tracer);
//startLine = (method_tracer.getCurrentSourceLine() + 1); // zero-based line index startLine = method_tracer.getCurrentSourceLine()+1; // zero-based line index
} }
else { else {
buffer.setLength(position); buffer.setLength(position);

Loading…
Cancel
Save