diff options
author | Martin Odersky <odersky@gmail.com> | 2015-11-29 17:25:22 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2015-11-30 17:31:32 +0100 |
commit | bced61d0bb58e8e4da1c7e8ececb1c24b5e81843 (patch) | |
tree | 0cf8308c7c0013a5061b0ab1af24353289d35d60 | |
parent | 0a96cbe590218ab022ccdb2950790fbab32dedcb (diff) | |
download | dotty-bced61d0bb58e8e4da1c7e8ececb1c24b5e81843.tar.gz dotty-bced61d0bb58e8e4da1c7e8ececb1c24b5e81843.tar.bz2 dotty-bced61d0bb58e8e4da1c7e8ececb1c24b5e81843.zip |
The change to do compareAlias early caused a dramatic slowdown of compilation
compileStdLib went from 45 sec to 230 sec. The problem were many redundant tests
when every member of an alias chain was compared to every other.
The new scheme follows alias chains to their end before doing anything else.
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 0d46a4b90..d94e24469 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -140,35 +140,35 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { private def firstTry(tp1: Type, tp2: Type): Boolean = tp2 match { case tp2: NamedType => - def compareAlias(info1: Type) = tp2.info match { - case info2: TypeAlias => isSubType(tp1, info2.alias) - case _ => info1 match { - case info1: TypeAlias => isSubType(info1.alias, tp2) - case _ => false - } - } def compareNamed = { - implicit val ctx: Context = this.ctx // Dotty deviation: implicits need explicit type - tp1 match { - case tp1: NamedType => - val sym1 = tp1.symbol - compareAlias(tp1.info) || - (if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) - ctx.erasedTypes || sym1.isStaticOwner || isSubType(tp1.prefix, tp2.prefix) - else - (tp1.name eq tp2.name) && - isSubType(tp1.prefix, tp2.prefix) && - (tp1.signature == tp2.signature) && - !tp1.isInstanceOf[WithFixedSym] && - !tp2.isInstanceOf[WithFixedSym] - ) || - compareHK(tp1, tp2, inOrder = true) || - compareHK(tp2, tp1, inOrder = false) || - thirdTryNamed(tp1, tp2) - case _ => - compareHK(tp2, tp1, inOrder = false) || - compareAlias(NoType) || - secondTry(tp1, tp2) + implicit val ctx: Context = this.ctx + tp2.info match { + case info2: TypeAlias => firstTry(tp1, info2.alias) + case _ => tp1 match { + case tp1: NamedType => + tp1.info match { + case info1: TypeAlias => firstTry(info1.alias, tp2) + case _ => + val sym1 = tp1.symbol + (if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) + ctx.erasedTypes || + sym1.isStaticOwner || + isSubType(tp1.prefix, tp2.prefix) || + thirdTryNamed(tp1, tp2) + else + (tp1.name eq tp2.name) && + isSubType(tp1.prefix, tp2.prefix) && + (tp1.signature == tp2.signature) && + !tp1.isInstanceOf[WithFixedSym] && + !tp2.isInstanceOf[WithFixedSym] || + compareHK(tp1, tp2, inOrder = true) || + compareHK(tp2, tp1, inOrder = false) || + thirdTryNamed(tp1, tp2)) + } + case _ => + compareHK(tp2, tp1, inOrder = false) || + secondTry(tp1, tp2) + } } } compareNamed |