Merged
Conversation
This was referenced Jul 13, 2020
Member
Author
kares
approved these changes
Jul 14, 2020
This eliminates the class for all remaining SizeFn inner class implementations and replaces all stateful inner class and lambda implementations of SizeFn with method references. This completes all requirements for jruby#4688. Method references are zero-alloc after the initial access, and are initialized lazily as opposed to anonymous inner classes (allocated every time) or static impl references (initialized at class init time). In addition, through the magic of lambdas this eliminates any remaining inner class instances, shrinking our class load slightly. The only controversial change here is the generification of SizeFn to allow the passed-in self to be of the same type as the object that serves as the enunmeration base. This might introduce some binary incompatibility with external libraries, but I do not know of any such libraries that implement their own SizeFn.
Member
Author
|
There's some quirks I have to work through here around Enumerator, since it seems the size function there needs to always operate against the enumerator rather than the object it wraps. Will return to this soon, but if someone else wants to try it you can see quick failures running |
97ef716 to
e6e15e0
Compare
* Always pass object through to sizeFn * Always use Enumerable sizeFn for new Enumerator
c231eb4 to
0aa6d46
Compare
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.
This is a cleaned-up merge of @anukin's changes in #4714.
The addition of
contexthappened separately as part of #5958, and as a result this PR only adds the "self" receiver to the SizeFn interface.This PR may be fine to include as-is, but none of the changes involved actually use the self object for anything. This PR as submitted only updates #4714 to merge properly.
Additional work to follow, which would then actually complete work described in #4688, would be to make all SizeFn objects static instances, using the passed in "self" to do the stateful calls they make now against the captured self. This would avoid the repeated allocation of the SizeFn instances for each enumerator produced by a given enumerable object.