8219014: (bf) Add absolute bulk put methods which accept a source Buffer
Brian Burkhalter
brian.burkhalter at oracle.com
Fri Feb 7 16:47:18 UTC 2020
> On Feb 7, 2020, at 8:17 AM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
>
>> On Feb 7, 2020, at 8:07 AM, Paul Sandoz <paul.sandoz at oracle.com <mailto:paul.sandoz at oracle.com>> wrote:
>>
>> Hmm… implementation-wise perhaps there is another approach. Make the implementation of the relative put defer to the absolute put. Thereby moving the implementations across with some minor adjustments rather than duplicating the code?
>
> That’s an interesting idea if it would work. Suppressing code duplication is almost always a good thing.
Changing the extant array relative bulk put to invoke the array absolute bulk put as
public $Type$Buffer put($type$[] src, int offset, int length) {
#if[rw]
checkSegment();
- Objects.checkFromIndexSize(offset, length, src.length);
int pos = position();
- if (length > limit() - pos)
- throw new BufferOverflowException();
- System.arraycopy(src, offset, hb, ix(pos), length);
+ put(pos, src, offset, length);
position(pos + length);
return this;
#else[rw]
throw new ReadOnlyBufferException();
#end[rw]
}
does not cause any Buffer regression tests to fail.
Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200207/aa5377fc/attachment.htm>
More information about the nio-dev
mailing list