summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Vierling <tv@duh.org>2014-05-09 13:09:49 -0400
committerTodd Vierling <tv@duh.org>2014-05-09 13:14:48 -0400
commitbed189ec8c373dfd429d424256dfbfcc17ac4221 (patch)
tree68a380815061ccf346fa18a892301f53c5272c7e
parent251616a107f4255203e318c9f6342f774d25e66d (diff)
downloadscala-bed189ec8c373dfd429d424256dfbfcc17ac4221.tar.gz
scala-bed189ec8c373dfd429d424256dfbfcc17ac4221.tar.bz2
scala-bed189ec8c373dfd429d424256dfbfcc17ac4221.zip
@inline Predef.identity[A].
Since identity[A] is often used as a function directly supplied to methods requiring (A)=>A, there's no need to have the generated Function1 object contain an explicit call to identity[A](). This implementation isn't going to change, so let the synthetic Function1 elide the extra call, generating just "aload_1; areturn".
-rw-r--r--src/library/scala/Predef.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index faeb1dcbe2..2be6a9dcc1 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -126,7 +126,7 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
def optManifest[T](implicit m: OptManifest[T]) = m
// Minor variations on identity functions
- def identity[A](x: A): A = x // @see `conforms` for the implicit version
+ @inline def identity[A](x: A): A = x // @see `conforms` for the implicit version
@inline def implicitly[T](implicit e: T) = e // for summoning implicit values from the nether world -- TODO: when dependent method types are on by default, give this result type `e.type`, so that inliner has better chance of knowing which method to inline in calls like `implicitly[MatchingStrategy[Option]].zero`
@inline def locally[T](x: T): T = x // to communicate intent and avoid unmoored statements