Skip to content

Commit

Permalink
perf: Collect list of source files only once (#1486)
Browse files Browse the repository at this point in the history
* perf: Collect list of source files only once

* one more useless call of sourcesFolder.getAllJavaFiles()

* added Deprecated tag
  • Loading branch information
pvojtechovsky authored and surli committed Jul 31, 2017
1 parent e6f0492 commit 72146e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public FileCompilerConfig(List<SpoonFile> files) {
this.files = files;
}

/*
* This method is not used now, so let's get rid of it.
*/
@Deprecated
public FileCompilerConfig(SpoonFolder folder) {
this(folder.getAllJavaFiles());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,20 +379,20 @@ protected boolean buildUnitsAndModel(JDTBuilder jdtBuilder, SpoonFolder sourcesF
private static final CompilationUnitDeclaration[] EMPTY_RESULT = new CompilationUnitDeclaration[0];

protected CompilationUnitDeclaration[] buildUnits(JDTBuilder jdtBuilder, SpoonFolder sourcesFolder, String[] classpath, String debugMessagePrefix, boolean buildOnlyOutdatedFiles) {
List<SpoonFile> sourceFiles = sourcesFolder.getAllJavaFiles();
List<SpoonFile> sourceFiles = Collections.unmodifiableList(sourcesFolder.getAllJavaFiles());
if (sourceFiles.isEmpty()) {
return EMPTY_RESULT;
}

JDTBatchCompiler batchCompiler = createBatchCompiler(new FileCompilerConfig(sourcesFolder));
JDTBatchCompiler batchCompiler = createBatchCompiler(new FileCompilerConfig(sourceFiles));

String[] args;
if (jdtBuilder == null) {
args = new JDTBuilderImpl() //
.classpathOptions(new ClasspathOptions().encoding(this.encoding).classpath(classpath)) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
.sources(new SourceOptions().sources(sourcesFolder.getAllJavaFiles())) // no sources, handled by the JDTBatchCompiler
.sources(new SourceOptions().sources(sourceFiles)) // no sources, handled by the JDTBatchCompiler
.build();
} else {
args = jdtBuilder.build();
Expand Down

0 comments on commit 72146e8

Please # to comment.