From c4bed34b009ffc54b1eac10ee75fba27040f1533 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 13 Feb 2014 14:50:04 +0100 Subject: Two performance optimizations 1) Split out wildApprox into separate function 2) Be more careful not to follow static prefix chains where not needed --- src/dotty/tools/dotc/core/TypeComparer.scala | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/dotty/tools/dotc/core/TypeComparer.scala') diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 1d2d4bac9..a8ad580a7 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -163,7 +163,8 @@ class TypeComparer(initctx: Context) extends DotClass { */ def approximation(param: PolyParam, fromBelow: Boolean): Type = { val avoidParam = new TypeMap { - override def apply(tp: Type) = mapOver { + override def stopAtStatic = true + def apply(tp: Type) = mapOver { tp match { case tp: RefinedType if param occursIn tp.refinedInfo => tp.parent case _ => tp @@ -269,18 +270,16 @@ class TypeComparer(initctx: Context) extends DotClass { def compareNamed = tp1 match { case tp1: NamedType => val sym1 = tp1.symbol - val sym2 = tp2.symbol - val pre1 = tp1.prefix - val pre2 = tp2.prefix - - ( if (sym1 == sym2) ( - ctx.erasedTypes + ( if (sym1 == tp2.symbol) ( + ctx.erasedTypes || sym1.isStaticOwner - || isSubType(pre1, pre2) - || pre1.isInstanceOf[ThisType] && pre2.isInstanceOf[ThisType] - ) - else - tp1.name == tp2.name && isSubType(pre1, pre2) + || { val pre1 = tp1.prefix + val pre2 = tp2.prefix + isSubType(pre1, pre2) || + pre1.isInstanceOf[ThisType] && pre2.isInstanceOf[ThisType] + } + ) else + tp1.name == tp2.name && isSubType(tp1.prefix, tp2.prefix) ) || secondTryNamed(tp1, tp2) case _ => secondTry(tp1, tp2) -- cgit v1.2.3