diff options
author | Martin Odersky <odersky@gmail.com> | 2012-08-16 20:03:14 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-08-20 08:11:06 +0100 |
commit | 1ee7ffb6fd2de6e7194a4eb89601d98503b50048 (patch) | |
tree | a7395953072397beb1435c4907cf4e23cbb4e469 /src/compiler | |
parent | 0cde930b192acc73d1e0b5951b3300c286ae4dd2 (diff) | |
download | scala-1ee7ffb6fd2de6e7194a4eb89601d98503b50048.tar.gz scala-1ee7ffb6fd2de6e7194a4eb89601d98503b50048.tar.bz2 scala-1ee7ffb6fd2de6e7194a4eb89601d98503b50048.zip |
Optimizations to cut down on #closures created
Driven by profile data.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 3cb33ec1f8..d97fbf5daa 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -488,7 +488,7 @@ abstract class Erasure extends AddInterfaces private def isPrimitiveValueMember(sym: Symbol) = sym != NoSymbol && isPrimitiveValueClass(sym.owner) - private def box(tree: Tree, target: => String): Tree = { + @inline private def box(tree: Tree, target: => String): Tree = { val result = box1(tree) log("boxing "+tree+":"+tree.tpe+" to "+target+" = "+result+":"+result.tpe) result diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index fc0f9370b4..1870e1511e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -661,7 +661,13 @@ trait Infer { val restp1 = followApply(restp) if (restp1 eq restp) tp else restp1 case _ => - val appmeth = tp.nonPrivateMember(nme.apply) filter (_.isPublic) + val appmeth = { + //OPT cut down on #closures by special casing non-overloaded case + // was: tp.nonPrivateMember(nme.apply) filter (_.isPublic) + val result = tp.nonPrivateMember(nme.apply) + if ((result eq NoSymbol) || !result.isOverloaded && result.isPublic) result + else result filter (_.isPublic) + } if (appmeth == NoSymbol) tp else OverloadedType(tp, appmeth.alternatives) } |