summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-06 02:34:53 +0000
committerPaul Phillips <paulp@improving.org>2011-06-06 02:34:53 +0000
commitb9731954fbdb7727b59d47095191638c53e3a2e7 (patch)
tree006598f9cecaa4ac5ce53f7d262728976ff8309a
parent1ebbe029dd7ba00444962c9b1493794032a17d6c (diff)
downloadscala-b9731954fbdb7727b59d47095191638c53e3a2e7.tar.gz
scala-b9731954fbdb7727b59d47095191638c53e3a2e7.tar.bz2
scala-b9731954fbdb7727b59d47095191638c53e3a2e7.zip
Working on the inliner, discovered that a few k...
Working on the inliner, discovered that a few key methods are not inlined. With this commit there are 326 fewer classfiles generated under -optimise. Use getOrElse with even wilder abandon than you were previously. No review.
-rw-r--r--src/library/scala/Option.scala4
-rw-r--r--src/library/scala/Predef.scala10
2 files changed, 7 insertions, 7 deletions
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index dfd647d649..81a079f723 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -105,7 +105,7 @@ sealed abstract class Option[+A] extends Product with Serializable {
*
* @param default the default expression.
*/
- def getOrElse[B >: A](default: => B): B =
+ @inline final def getOrElse[B >: A](default: => B): B =
if (isEmpty) default else this.get
/** Returns the option's value if it is nonempty,
@@ -117,7 +117,7 @@ sealed abstract class Option[+A] extends Product with Serializable {
* val textField = new JComponent(initalText.orNull,20)
* }}}
*/
- def orNull[A1 >: A](implicit ev: Null <:< A1): A1 = this getOrElse null
+ @inline final def orNull[A1 >: A](implicit ev: Null <:< A1): A1 = this getOrElse null
/** Returns a $some containing the result of applying $f to this $option's
* value if this $option is nonempty.
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 68fdee8411..43bf4181ec 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -97,8 +97,8 @@ object Predef extends LowPriorityImplicits {
* @param p the expression to test
* @param msg a String to include in the failure message
*/
- @elidable(ASSERTION)
- def assert(assertion: Boolean, message: => Any) {
+ @elidable(ASSERTION) @inline
+ final def assert(assertion: Boolean, message: => Any) {
if (!assertion)
throw new java.lang.AssertionError("assertion failed: "+ message)
}
@@ -128,8 +128,8 @@ object Predef extends LowPriorityImplicits {
* @param p the expression to test
* @param msg a String to include in the failure message
*/
- @elidable(ASSERTION)
- def assume(assumption: Boolean, message: => Any) {
+ @elidable(ASSERTION) @inline
+ final def assume(assumption: Boolean, message: => Any) {
if (!assumption)
throw new java.lang.AssertionError("assumption failed: "+ message)
}
@@ -152,7 +152,7 @@ object Predef extends LowPriorityImplicits {
* @param p the expression to test
* @param msg a String to include in the failure message
*/
- def require(requirement: Boolean, message: => Any) {
+ @inline final def require(requirement: Boolean, message: => Any) {
if (!requirement)
throw new IllegalArgumentException("requirement failed: "+ message)
}