diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-30 06:08:41 +0100 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-27 15:47:32 -0800 |
commit | 9a6320b882495e93210b0e11dad02271306d83d2 (patch) | |
tree | 82f70d3b572c4ba8c72842cac97fa512a21762c9 /src/reflect | |
parent | 2e3e43b5971ab93b04ab4677fe23a81bb3291470 (diff) | |
download | scala-9a6320b882495e93210b0e11dad02271306d83d2.tar.gz scala-9a6320b882495e93210b0e11dad02271306d83d2.tar.bz2 scala-9a6320b882495e93210b0e11dad02271306d83d2.zip |
Eliminate allocations in BaseTypeSeqs.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/BaseTypeSeqs.scala | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index eba10e8ffb..18a4a36840 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -193,15 +193,23 @@ trait BaseTypeSeqs { i += 1 } var minTypes: List[Type] = List() + def alreadyInMinTypes(tp: Type): Boolean = { + @annotation.tailrec def loop(tps: List[Type]): Boolean = tps match { + case Nil => false + case x :: xs => (tp =:= x) || loop(xs) + } + loop(minTypes) + } + i = 0 while (i < nparents) { if (nextTypeSymbol(i) == minSym) { nextRawElem(i) match { case RefinedType(variants, decls) => for (tp <- variants) - if (!(minTypes exists (tp =:= _))) minTypes = tp :: minTypes + if (!alreadyInMinTypes(tp)) minTypes ::= tp case tp => - if (!(minTypes exists (tp =:= _))) minTypes = tp :: minTypes + if (!alreadyInMinTypes(tp)) minTypes ::= tp } index(i) = index(i) + 1 } |