Skip to content

Commit a0a184e

Browse files
committed
Make the condition of assert a call-by-name argument.
This generates more efficient code by inlining the argument expression into the if-then-else.
1 parent 1f2ca04 commit a0a184e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/src/dotty/DottyPredef.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ object DottyPredef {
2424
*/
2525
abstract class ImplicitConverter[-T, +U] extends Function1[T, U]
2626

27-
@forceInline final def assert(assertion: Boolean, message: => Any): Unit = {
27+
@forceInline final def assert(assertion: => Boolean, message: => Any): Unit = {
2828
if (!assertion)
2929
assertFail(message)
3030
}
3131

32-
@forceInline final def assert(assertion: Boolean): Unit = {
32+
@forceInline final def assert(assertion: => Boolean): Unit = {
3333
if (!assertion)
3434
assertFail()
3535
}

0 commit comments

Comments
 (0)