Skip to content

Commit dcb3eec

Browse files
ntreldlang-bot
authored andcommitted
[tools/dspec_tester] Only call readText once per file
1 parent 7a209db commit dcb3eec

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tools/dspec_tester.d

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ int main(string[] args)
113113
return 1;
114114
}
115115

116-
// Find all examples in the specification
117-
alias findExamples = (file, ddocKey) => file
118-
.readText
119-
.findDdocMacro(ddocKey)
120-
.map!ddocMacroToCode;
121-
122116
alias SpecType = Tuple!(string, "key", CompileConfig.TestMode, "mode");
123117
auto specTypes = [
124118
SpecType("$(SPEC_RUNNABLE_EXAMPLE_COMPILE", CompileConfig.TestMode.compile),
@@ -139,7 +133,12 @@ int main(string[] args)
139133
modImport = modImport.findSplitBefore(dirSeparator ~ "package")[0];
140134
modImport = modImport.replace(dirSeparator, ".");
141135
}
142-
auto allTests = specTypes.map!(c => findExamples(file, c.key)
136+
const text = file.readText;
137+
// Find all examples in the specification
138+
alias findExamples = (ddocKey) => text
139+
.findDdocMacro(ddocKey)
140+
.map!ddocMacroToCode;
141+
auto allTests = specTypes.map!(c => findExamples(c.key)
143142
.map!(e => compileAndCheck(e, CompileConfig(c.mode), modImport)))
144143
.joiner;
145144
if (!allTests.empty)

0 commit comments

Comments
 (0)