-
Notifications
You must be signed in to change notification settings - Fork 41
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
[6.0] Improve collections equality #1011
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please address the comments
java.util.Objects.deepEquals(obj.toArray, this.toArray) | ||
case obj: PairColl[_, _] if obj.tItem == this.tItem => | ||
if(VersionContext.current.isV6SoftForkActivated) { | ||
java.util.Objects.deepEquals(obj.toArray, this.toArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the obj.toArray
will lead to many allocations (one for the array, and one for each pair). It is better to avoid it allocations in equals
. Here it can be done by accessing obj.ls
, obj.rs
and comparing with this.toArray in a cfor loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, please check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
ls == that.ls && rs == that.rs | ||
case that: CollOverArray[_] if that.tItem == this.tItem => | ||
if (VersionContext.current.isV6SoftForkActivated) { | ||
java.util.Objects.deepEquals(that.toArray, this.toArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison loop above (once implemented) can be reused here to avoid allocations.
In this PR, PairOfColl made equal with CollOverArray (when contents is the same), starting from 6.0 version of the protocol
close #909