diff options
author | Paul Phillips <paulp@improving.org> | 2013-03-13 06:18:53 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-13 06:20:00 -0700 |
commit | 6ef63e49f8d762ac02367225ee737ea93f52a738 (patch) | |
tree | 76dd136c18c65f2dbf52b43b7e4758672bb31154 | |
parent | 9c5ea96b1c0fa45037a96e530b6ae71687a292d1 (diff) | |
download | scala-6ef63e49f8d762ac02367225ee737ea93f52a738.tar.gz scala-6ef63e49f8d762ac02367225ee737ea93f52a738.tar.bz2 scala-6ef63e49f8d762ac02367225ee737ea93f52a738.zip |
Fix it-never-happened performance regression.
Diligent reviewer observed that a hot spot was possibly
being made hotter. Reviewer's suggested remedy was a
spectacular bust, but studious observation revealed the news
lash that expensive methods are expensive and we should
avoid calling them if we can.
Put short-circuit test back in front of unapply call.
Now the time spent in unapply is within a few percent.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 29d4c8423b..5b11adf127 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -573,15 +573,16 @@ trait Implicits { ) def fail(reason: String): SearchResult = failure(itree, reason) + def fallback = typed1(itree, EXPRmode, wildPt) try { - val itree1 = pt match { - case Function1(arg1, arg2) if isView => + val itree1 = if (!isView) fallback else pt match { + case Function1(arg1, arg2) => typed1( atPos(itree.pos)(Apply(itree, List(Ident("<argument>") setType approximate(arg1)))), EXPRmode, approximate(arg2) ) - case _ => typed1(itree, EXPRmode, wildPt) + case _ => fallback } if (context.hasErrors) { log("implicit adapt failed: " + context.errBuffer.head.errMsg) |