Choosechee opened a new pull request, #2256:
URL: https://github.com/apache/groovy/pull/2256
I have made some changes to `Tuple` that are related to its backing array.
One of them fixes a pretty major bug I found:
- Made `Tuple` implement `RandomAccess`.
- Currently, `Tuple`'s 'toArray()' returns its backing array. This is
_extremely_ bad, because modifying this array affects the `Tuple`, which is
supposed to be immutable. Additionally, it breaks the contract of
`Collection.toArray()`:
> The returned array will be "safe" in that no references to it are
maintained by this collection. (In other words, this method must allocate a new
array even if this collection is backed by an array). The caller is thus free
to modify the returned array.
I have made it return a copy of the array instead.
- Overrode `toArray(T[])` with an implementation that uses
`System.arraycopy`, for better performance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]