RFR: 4860681: (bf) Add CharBuffer absolute bulk put method for CharSequence

ExE Boss duke at openjdk.org
Thu Jul 13 15:18:25 UTC 2023


On Mon, 1 May 2023 20:15:10 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Add to `java.nio.CharBuffer` an absolute bulk put method which takes a `CharSequence` as its source of `char`s.

src/java.base/share/classes/java/nio/X-Buffer.java.template line 1463:

> 1461:      * that is, if
> 1462:      * <code>end - start</code> {@code >} 
> 1463:      * {@code limit()} - {@code index},

Suggestion:

     * <code>end - start > limit() - index</code>,

src/java.base/share/classes/java/nio/X-Buffer.java.template line 1490:

> 1488:      * <ul>
> 1489:      * <li>defines the range of characters to be read from the source in terms
> 1490:      * of the half-open interval {@code [start,} {@code  end)} instead of

Suggestion:

     * of the half-open interval <code>[start, end)</code> instead of

src/java.base/share/classes/java/nio/X-Buffer.java.template line 1495:

> 1493:      * {@code IndexOutOfBoundsException} for the condition
> 1494:      * {@code index} {@code +} {@code end} {@code -} 
> 1495:      * {@code start} {@code >} {@code limit()}.</li>

Suggestion:

     * <code>index + end - start > limit()</code>.</li>

src/java.base/share/classes/java/nio/X-Buffer.java.template line 1529:

> 1527:      * @see #append(CharSequence,int,int)
> 1528:      * @see #put(int,$type$[],int,int)
> 1529:      * @see #put(int,$Type$Buffer,int,int)

Suggestion:

     * @see #append(CharSequence, int, int)
     * @see #put(int, $type$[], int, int)
     * @see #put(int, $Type$Buffer, int, int)

src/java.base/share/classes/java/nio/X-Buffer.java.template line 1541:

> 1539: 
> 1540:         for (int i = start; i < end; i++)
> 1541:             this.put(index++, csq.charAt(i));

This should probably include the `String::getBytes`, `StringBuffer::getBytes`, and `StringBuilder::getBytes` optimisation that `CharBuffer::append(CharSequece, int, int)` has as of [JDK‑8305811] ([GH‑13415]) and [JDK‑8306374] ([GH‑13522]).

[JDK‑8305811]: https://bugs.openjdk.org/browse/JDK-8305811 "[JDK‑8305811] (bf) Improve performance of CharBuffer::append(CharSequence[,int,int])"
[JDK‑8306374]: https://bugs.openjdk.org/browse/JDK-8306374 "[JDK‑8306374] (bf) Improve performance of DirectCharBuffer::append(CharSequence[,int,int])"
[GH‑13415]: https://github.com/openjdk/jdk/pull/13415
[GH‑13522]: https://github.com/openjdk/jdk/pull/13522

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1184644247
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1184524414
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1184643591
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1184644794
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1184648752


More information about the nio-dev mailing list