Skip to content

Commit 4bb0a1f

Browse files
committed
Avoid expensive computations in Stats.record calls
When `Stats.enabled` is false, `Stats.record` should be free, but before this commit this wasn't the case: since the `n` passed to `record` was by-value, it had to be evaluated, this is very expensive for calls like: record("retained typed trees after typer", unit.tpdTree.treeSize) Before this commit, we got after inlining: val n = unit.tpdTree.treeSize Now we get: def n = unit.tpdTree.treeSize it'd be even nicer if we didn't generate anything at all, but this shouldn't have much impact on running time.
1 parent 58b5203 commit 4bb0a1f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/src/dotty/tools/dotc/util/Stats.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import collection.mutable
2121
}
2222

2323
@inline
24-
def record(fn: String, n: Int = 1) =
24+
def record(fn: => String, n: => Int = 1) =
2525
if (enabled) doRecord(fn, n)
2626

2727
private def doRecord(fn: String, n: Int) =

0 commit comments

Comments
 (0)