summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Garcia <miguelalfredo.garcia@epfl.ch>2013-01-04 13:57:19 +0100
committerMiguel Garcia <miguelalfredo.garcia@epfl.ch>2013-01-04 13:57:19 +0100
commitb2bd8253663056be265af4cb1788b852fc627fa2 (patch)
tree5a70f9142b694bf016b3d81679b1a99402cdb513
parent653b29bfdd091d7e2c069b8ad56f8ca51ad4b244 (diff)
downloadscala-b2bd8253663056be265af4cb1788b852fc627fa2.tar.gz
scala-b2bd8253663056be265af4cb1788b852fc627fa2.tar.bz2
scala-b2bd8253663056be265af4cb1788b852fc627fa2.zip
comments on avoiding closure allocation in Global's assert() and require()
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala2
1 files changed, 2 insertions, 0 deletions
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))
}