Permalink
Browse files

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.
  • Loading branch information...
1 parent 9c5ea96 commit 6ef63e49f8d762ac02367225ee737ea93f52a738 @paulp paulp committed Mar 13, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 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)

0 comments on commit 6ef63e4

Please sign in to comment.