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

Call ArrayUtil.copyArray instead of ArrayUtil.copySubArray for full array copy. #13360

Merged
merged 4 commits into from May 14, 2024

Conversation

bruno-roustant
Copy link
Contributor

@bruno-roustant bruno-roustant commented May 11, 2024

ArrayUtil provides copySubArray() as replacement of Array.copyOf and Array.copyOfRange (with better bounds check). Unfortunately ArrayUtil does not provide copyArray(), so it is weird for callers to have to call a method named copySubArray() when we want to copy the full array.

This PR adds ArrayUtil.copyArray(), and replaces the calls to ArrayUtil.copySubArray(array, 0, array.length) with calls to ArrayUtil.copyArray(array).
I used the following regex to match all calls:
copyOfSubArray\(([^,]+), 0, \1\.length\)
and this one to replace
copyArray($1)

@bruno-roustant bruno-roustant changed the title Call ArrayUtil.copyOf instead of ArrayUtil.copySubArray for full array copy. Call ArrayUtil.copyArray instead of ArrayUtil.copySubArray for full array copy. May 13, 2024
@bruno-roustant bruno-roustant merged commit bcb62f5 into apache:main May 14, 2024
3 checks passed
@bruno-roustant bruno-roustant deleted the array_copyof branch May 14, 2024 09:33
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.

None yet

2 participants