Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Every time method foo is called, a little function closure is allocated for the 'b' argument passing.

A 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 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)

...