From b2bd8253663056be265af4cb1788b852fc627fa2 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Fri, 4 Jan 2013 13:57:19 +0100 Subject: comments on avoiding closure allocation in Global's assert() and require() --- src/compiler/scala/tools/nsc/Global.scala | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 20b8265071..8746a7fd8d 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -228,6 +228,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) // of assert and require (but for now I've reproduced them here, // because there are a million to fix.) @inline final def assert(assertion: Boolean, message: => Any) { + // calling Predef.assert would send a freshly allocated closure wrapping the one received as argument. if (!assertion) throw new java.lang.AssertionError("assertion failed: "+ supplementErrorMessage("" + message)) } @@ -235,6 +236,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) assert(assertion, "") } @inline final def require(requirement: Boolean, message: => Any) { + // calling Predef.require would send a freshly allocated closure wrapping the one received as argument. if (!requirement) throw new IllegalArgumentException("requirement failed: "+ supplementErrorMessage("" + message)) } -- cgit v1.2.3