Skip to content

Optimize findRef #4156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2018
Merged

Optimize findRef #4156

merged 2 commits into from
Mar 26, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 22, 2018

... by inlining two frequently used local methods

odersky added 2 commits March 22, 2018 15:44
... by inlining two frequently used submethods
I noted this happening from tyoime to time in the IDE, and it is super annoying
when it happens. Let's see if we can survive meaningfully after ignoring this condition.
@odersky
Copy link
Contributor Author

odersky commented Mar 22, 2018

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 1 running.

@@ -549,7 +549,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
if (inst.exists) sigName(inst) else tpnme.Uninstantiated
case tp: TypeProxy =>
sigName(tp.underlying)
case _: ErrorType | WildcardType =>
case _: ErrorType | WildcardType | NoType =>
tpnme.WILDCARD
case tp: WildcardType =>
sigName(tp.optBounds)
Copy link
Contributor

@Blaisorblade Blaisorblade Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code match twice against WildcardType? I don't get it. In fact, the latter matches appear to be erased away:

scala> def foo: Any => Any = { case _: String | Int => 1; case _: Int => 2 }
def foo: Any => Any
scala> foo(1)
val res0: Any = 2
scala> def foo: Any => Any = { case _: String | AnyRef => 1; case _: AnyRef => 2 }
def foo: Any => Any
scala> foo(new AnyRef())
val res1: Any = 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It first matches against the object WildcardType, then the case below matches against any instance of the class WildcardType.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry, Allan explained me what's going on. But do we really know that the only instance of WildcardType(NoType) is the WildcardType object?

case _ =>
go(tp.superType)
}
case tp: ThisType => // ??? inline
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray comment?

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/4156/ to see the changes.

Benchmarks is based on merging with master (0c5e39d)

Blaisorblade added a commit to dotty-staging/dotty that referenced this pull request Mar 22, 2018
@odersky odersky merged commit 477ebee into scala:master Mar 26, 2018
@allanrenucci allanrenucci deleted the opt-findRef branch March 26, 2018 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants