diff --git a/tlatools/org.lamport.tlatools/src/tlc2/debug/TLCStackFrame.java b/tlatools/org.lamport.tlatools/src/tlc2/debug/TLCStackFrame.java index 936e4882f4..ff440024f5 100644 --- a/tlatools/org.lamport.tlatools/src/tlc2/debug/TLCStackFrame.java +++ b/tlatools/org.lamport.tlatools/src/tlc2/debug/TLCStackFrame.java @@ -25,7 +25,6 @@ ******************************************************************************/ package tlc2.debug; -import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -49,6 +48,9 @@ class TLCStackFrame extends StackFrame { + // Not thread-safe because TLCDebugger is assumed to take care of synchronization! + private static final Map PATH_CACHE = new HashMap<>(); + public static final String SCOPE = "Context"; // It would be easier to use hashCode instead of passing a random generator @@ -90,8 +92,10 @@ public TLCStackFrame(SemanticNode node, Context ctxt, final Tool tool) { final Source source = new Source(); source.setName(node.getLocation().source()); - final File moduleFile = tool.getResolver().resolve(node.getTreeNode().getFilename(), true); - source.setPath(moduleFile.getAbsolutePath().toString()); + // resolve(..) triggers a file-system round-trip (IO), which is obviously too + // expensive!!! Thus, cache the result. + source.setPath(PATH_CACHE.computeIfAbsent(node, + n -> tool.getResolver().resolve(n.getTreeNode().getFilename(), true).getAbsolutePath().toString())); setSource(source); this.stackId = rnd.nextInt(Integer.MAX_VALUE - 1) + 1;