Introduce a new implementation of implicit shadowing#8109
Merged
retronym merged 2 commits intoscala:2.12.xfrom Jun 24, 2019
Merged
Introduce a new implementation of implicit shadowing#8109retronym merged 2 commits intoscala:2.12.xfrom
retronym merged 2 commits intoscala:2.12.xfrom
Conversation
Avoid building up a set of all in-scope implicits during each implicit search. Instead, do the filtering of shadowed implicits in a second pass.
With an opt-out system property
Member
Author
|
Less ambitious version of #7757 which has proved hard to get over the line. |
retronym
commented
May 29, 2019
| // Collect candidates, the level at which each was found and build a set of their names | ||
| var iss = this.iss | ||
| while (!iss.isEmpty) { | ||
| var is = iss.head |
Member
Author
There was a problem hiding this comment.
While loops avoid ObjectRef-s here for the captured vars.
Contributor
There was a problem hiding this comment.
I was going to lint that after ichoran mentioned how pernicious it is.
Member
Author
|
Comparing execution time, again for Measuring allocation rate improvements: 0.90x reduction. |
Member
Author
|
Scheduled a community build (link 404 until Seth provides the witticism) on the first commit, which is a bake-off between the old and new implementation that asserts identical results. |
diesalbla
reviewed
Jun 1, 2019
| /** Sorted list of eligible implicits. | ||
| */ | ||
| private def eligibleNew = { | ||
| final case class Candidate(info: ImplicitInfo, level: Int) |
Contributor
There was a problem hiding this comment.
- As a farther step to remove extra allocations, we can unzip the
matchesarray into anArray[ImplicitInfo]and anArray[Int], and thus get rid of theCandidateclass. - Going farther, and assuming that 255 levels should be enough for anyone, perhaps we could make
levelinto anArray[Byte]?
diesalbla
approved these changes
Jun 2, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid building up a set of all in-scope implicits during each implicit
search.
Instead, do the filtering of shadowed implicits in a second pass.