...
Every time method foo is called, a little function closure is allocated for the 'b' argument passing.
Probably the worst offender in this is
Code Block |
---|
val opt : Option[Foo] = ....
opt.getOrElse(Assert.invariantFailed("opt should be defined")) // allocates closure around assertion. |
So don't call getOrElse in performance code!
In our own classes, a A macro can often be used instead to avoid the need for the by-name argument. (See AssertMacros.scala and/or LoggerMacros.scala for examples of this)
...