forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Submerge the Variance extractor function into the solve functions.
In the `solvedTypes` and the `solve` functions, there is a third parameter to give the specific variances, in the context of the resolution, of each parameter which goes in the second parameter. In fact, this `variances` list is always a `map` of a function, which is different in each call, on the second list of symbols. We replace the third parameter from being the list of variances to being the function that is used to get that third list, and thus merge the application of that list in each step of the foreach. This has these benefits: - We avoid allocating the list of variances, particularly for the case in which we are just using a constant function to Invariant, before the call. - Since the only relevant information is whether or not a type parameter is contravariant, which is one bit (boolean), we use a BitSet to store that information. - To use a BitSet, we need indices, so in the solve we replace the use of map and foreach, by the utility foreachWithIndex. - By using a Variance.Extractor instead of a Function1, as required by the List.map function, we can avoid allocations of Variance objects, and use instead the underlying integer value. There could be a small performance prejudice: the double-nested loop of the solve method could compute the variances up to N times.
- Loading branch information
Showing
7 changed files
with
36 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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