On Mon, 27 Feb 2023 13:30:47 GMT, Jim Laskey <[email protected]> wrote:
>> Add the ability to repeatedly append char and CharSequence data to
>> StringBuilder/StringBuffer.
>
> Jim Laskey has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Optimize for empty CharSequence
src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1879:
> 1877: * @since 21
> 1878: * @throws IllegalArgumentException if {@code count} is less than
> zero
> 1879: * @throws IndexOutOfBoundsException if the result overflows the
> buffer
Can `IndexOutOfBoundsException` be really thrown? We don't have any index here.
From the implementation I see that only `OutOfMemoryError` and
`IllegalArgumentException` can be thrown.
Also, I see a small descrepancy between messages in this method and
`String.repeat`. The latter has:
* @throws IllegalArgumentException if the {@code count} is
* negative.
*
* @since 11
*/
public String repeat(int count) {
if (count < 0) {
throw new IllegalArgumentException("count is negative: " + count);
}
Probably it's better to reuse the same wording ("is negative" instead of "is
less than zero") for consistency?
-------------
PR: https://git.openjdk.org/jdk/pull/12728