-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use Arrays#mismatch for Outputs#common operations #12710
Conversation
// no common prefix | ||
return NO_OUTPUT; | ||
} else if (pos1 == output1.offset + output1.length) { | ||
} else if (mismatchPos == -1) { |
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.
Why aren't we merging these 2 branches?
else if (mismatchPos == -1 || mismatchPos == output1.length)
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.
Just for better comment to explain. Will merge if you think this way is better :)
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.
Either way would look good to me.
// output2 is a prefix of output1 | ||
return output2; | ||
} else { | ||
return new IntsRef(output1.ints, output1.offset, pos1 - output1.offset); | ||
return new IntsRef(output1.ints, output1.offset, mismatchPos); |
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.
I had a previous comment about this length parameter, but it seems mismatchPos
will return the relative index, so that's ok. Just added here for posterity.
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
Make
Outputs#common
take advantage ofArrays#mismatch
.