Skip to content

Commit 6c172db

Browse files
committed
Avoid too eager computation in reporting.
I noted a slowdown of about 25% (66sec -> 81sec) when compiling dotty even after the subtype optimization (before it was 117sec). I tracked it down to the traceIndented fix which avoided questions to be evaluated twice. But it also caused the question to be evaluated Making the val lazy fixed the problem.
1 parent 601d72c commit 6c172db

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ trait Reporting { this: Context =>
155155
else {
156156
// Avoid evaluating question multiple time, since each evaluation
157157
// may cause some extra logging output.
158-
val q: String = question
158+
lazy val q: String = question
159159
traceIndented[T](s"==> $q?", (res: Any) => s"<== $q = ${resStr(res)}")(op)
160160
}
161161
}

0 commit comments

Comments
 (0)