Make identity hashing aware of JavaProxy#8614
Draft
headius wants to merge 1 commit intojruby:masterfrom
Draft
Conversation
This change makes compare_by_identity Hash instances know about our JavaProxy wrapper type and treat as identical two wrappers that contain the same object. This will add overhead to all identity hashes in order to type check the incoming keys: * It must know to calculate the identity hash based on the contained object and not the wrapper (affects all identity Hash). * It must also try to unwrap proxies and compare contents when traversing existing entries (only affects identity Hash when a key does not already exist). This fixes the identity Hash portion of jruby#8612.
Member
Author
|
This needs tests but I think we are pretty safe including it in an upcoming release. It does not appear to be necessary to fix issues in @kalenp's application, so there's no rush to include it in 9.4.12.0. After discussion we decided that we could not think of a case where someone would not want two equivalent Java object wrappers to appear identical to an identity Hash, and lots of reasons why that behavior is almost certainly unexpected. Since currently it's just broken, as illustrated by my example in #8612, this is a net positive functionality fix. Note I have not done any benchmarking to see how the additional type-checking affects identity Hash performance, so that should happen before merge as well. |
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 change makes compare_by_identity Hash instances know about our JavaProxy wrapper type and treat as identical two wrappers that contain the same object. This will add overhead to all identity hashes in order to type check the incoming keys:
This fixes the identity Hash portion of #8612.