RFR: 4860681: (bf) Add CharBuffer absolute bulk put method for CharSequence
Brian Burkhalter
bpb at openjdk.org
Thu Jul 13 15:18:25 UTC 2023
On Thu, 4 May 2023 04:13:47 GMT, ExE Boss <duke 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 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
I was under the perhaps mistaken impression that `{@code ...}` is preferred to `<code>...</code>` these days.
> 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)
So changed in ef652e7.
> 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
> This should probably include the `String::getBytes`, `StringBuffer::getBytes`, and `StringBuilder::getBytes` optimisation that `CharBuffer::append(CharSequece, int, int)` has as of [JDK‑8305811](https://bugs.openjdk.org/browse/JDK-8305811) ([GH‑13415](https://github.com/openjdk/jdk/pull/13415)) and [JDK‑8306374](https://bugs.openjdk.org/browse/JDK-8306374) ([GH‑13522](https://github.com/openjdk/jdk/pull/13522)).
Clearly. That's why this is a draft PR. The optimizations are intentionally omitted until consensus is achieved on the specification. I prefer not to redo the heap and direct overrides if it is at all avoidable.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1185490867
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1185504217
PR Review Comment: https://git.openjdk.org/jdk/pull/13744#discussion_r1185493363
More information about the nio-dev
mailing list