Skip to content

Commit

Permalink
Merge pull request #1 from deepdik/feature/optimization
Browse files Browse the repository at this point in the history
Optimize file reading by switching to stream-based comment filtering
  • Loading branch information
deepdik authored Nov 14, 2024
2 parents 3871374 + 6710f4a commit 3e3bb37
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions showcases/src/test/java/org/example/ShowcaseCompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ private static Set<Path> getShowcaseFilePaths(Path showcaseDirectory)
public void processShowcaseFile() throws IOException
{
// Stripping comments required as parser will remove them
String pureGrammar = Files.readAllLines(showcasePath).stream()
.filter(l -> !l.stripLeading().startsWith("//"))
String pureGrammar;
try (Stream<String> lines = Files.lines(showcasePath)) {
pureGrammar = lines
.filter(line -> !line.stripLeading().startsWith("//"))
.collect(Collectors.joining("\n"));
}

assumeFalse(pureGrammar.isEmpty());

Expand Down

0 comments on commit 3e3bb37

Please sign in to comment.