summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-03 11:53:17 -0800
committerPaul Phillips <paulp@improving.org>2012-12-17 17:47:59 -0800
commit5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07 (patch)
treeb2e850946257461fe20941b078da6be3f42273be /src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
parente14917528e1c080a7f10785e21de36f3a7769718 (diff)
downloadscala-5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07.tar.gz
scala-5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07.tar.bz2
scala-5f1e18b1cd8f76f40bb01d257ae3b81cb70e3e07.zip
Optimization in SpecializeTypes.
Avoid time traveling to find type parameters which will never be there.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 4e4c1b98ac..e3239313de 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -403,11 +403,16 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case _ => false
})
def specializedTypeVars(tpes: List[Type]): immutable.Set[Symbol] = {
- val buf = Set.newBuilder[Symbol]
- tpes foreach (tp => buf ++= specializedTypeVars(tp))
- buf.result
+ if (tpes.isEmpty) immutable.Set.empty else {
+ val buf = Set.newBuilder[Symbol]
+ tpes foreach (tp => buf ++= specializedTypeVars(tp))
+ buf.result
+ }
}
- def specializedTypeVars(sym: Symbol): immutable.Set[Symbol] = enteringTyper(specializedTypeVars(sym.info))
+ def specializedTypeVars(sym: Symbol): immutable.Set[Symbol] = (
+ if (definitions.neverHasTypeParameters(sym)) immutable.Set.empty
+ else enteringTyper(specializedTypeVars(sym.info))
+ )
/** Return the set of @specialized type variables mentioned by the given type.
* It only counts type variables that appear:
@@ -436,7 +441,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case AnnotatedType(_, tp, _) => specializedTypeVars(tp)
case TypeBounds(lo, hi) => specializedTypeVars(lo :: hi :: Nil)
case RefinedType(parents, _) => parents flatMap specializedTypeVars toSet
- case _ => Set()
+ case _ => immutable.Set.empty
}
/** Returns the type parameter in the specialized class `sClass` that corresponds to type parameter