8245121: (bf) XBuffer.put(Xbuffer src) can give unexpected result when storage overlaps
Brian Burkhalter
brian.burkhalter at oracle.com
Fri May 29 00:57:47 UTC 2020
> On May 28, 2020, at 5:21 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>
> Here’s a tip, rather than creating a fixed size array upfront:
>
> - create a List<Object[]> to add argument list combinations to
> - add with args.add(new Object[] {proxy})
> - at the end do args.toArray(Object[][]::new)
Cool - thanks!
> For:
>
> 281 List<BufferProxy> proxies1 = getProxies(type);
> 282 List<BufferProxy> proxies2 = getProxies(type);
> 283 for (BufferProxy proxy1 : proxies1) {
> 284 for (BufferProxy proxy2 : proxies2) {
> 285 data[index][0] = proxy1;
> 286 data[index++][1] = proxy2;
> 287 }
> 288 }
>
> Can you reuse proxy1 since the list is not modified and the proxy is stateless w.r.t. Buffers? Is it necessary to test when proxy1 == proxy2 i.e. the diagonal?
Good point. Yes I think it can be re-used as there is no relevant state. I don’t think it’s necessary to check for proxy1 == proxy2: we want to test the case where both are the same type, kind, and order.
> It’s useful to try the streams approach as an exercise, I can imagine some people might find nested flatMaps a little jarring. The nested loops are fine here.
The updated version is at
http://cr.openjdk.java.net/~bpb/8245121/webrev.04/
It keeps getting shorter!
Thanks,
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200528/69169b95/attachment.htm>
More information about the nio-dev
mailing list