Skip to content
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

Merged
merged 3 commits into from
Oct 25, 2023

Conversation

gf2121
Copy link
Contributor

@gf2121 gf2121 commented Oct 23, 2023

Make Outputs#common take advantage of Arrays#mismatch.

// no common prefix
return NO_OUTPUT;
} else if (pos1 == output1.offset + output1.length) {
} else if (mismatchPos == -1) {
Copy link
Contributor

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)

Copy link
Contributor Author

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 :)

Copy link
Contributor

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);
Copy link
Contributor

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.

@gf2121 gf2121 added this to the 9.9.0 milestone Oct 24, 2023
Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gf2121 gf2121 merged commit 676dceb into apache:main Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants