From d31eadc2772b0937b1df2b48f76d9f3f86c0a852 Mon Sep 17 00:00:00 2001 From: Vic Nightfall Date: Sat, 27 Apr 2024 22:44:09 +0200 Subject: [PATCH] Don't load source files twice --- src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index a77ff228..b1b2aa2f 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -666,6 +666,7 @@ public class JavaTXCompiler { public final Map loadedClasses = new HashMap<>(); private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException { + if (sourceFiles.containsKey(sourceFile)) return sourceFiles.get(sourceFile); SourceFileContext tree = JavaTXParser.parse(sourceFile); environment.addClassesToRegistry(classRegistry, tree, sourceFile, this); SyntaxTreeGenerator generator = new SyntaxTreeGenerator(this, classRegistry, new GenericsRegistry(null), sourceFile.getName()); @@ -740,7 +741,9 @@ public class JavaTXCompiler { var sf = sourceFiles.get(sourceFile); if (sf.isGenerated()) return null; List typeinferenceResult = this.typeInference(sourceFile); - return generateBytecode(sf, typeinferenceResult); + var classes = generateBytecode(sf, typeinferenceResult); + sf.setGenerated(); + return classes; } private Map> generatedGenerics = new HashMap<>();