Skip to content

Commit

Permalink
@inline Predef.identity[A].
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
tvierling committed May 9, 2014
1 parent 251616a commit bed189e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/library/scala/Predef.scala
Expand Up @@ -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

Expand Down

0 comments on commit bed189e

Please sign in to comment.