On Thu, 23 Feb 2023 16:20:59 GMT, Jim Laskey <jlas...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1867: >> >>> 1865: >>> 1866: private AbstractStringBuilder repeatNull(int count) { >>> 1867: if (count < 0) { >> >> This could be implemented as `repeat("null", count)`. Its not likely to be >> performance sensitive and be easier to maintain. > > Just being consistent with existing code. Better to add less code to maintain later. >> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1879: >> >>> 1877: throw new OutOfMemoryError("Required length exceeds >>> implementation limit"); >>> 1878: } >>> 1879: int limit = count * length; >> >> The meaning of limit should be consistent across uses. Above it is an index >> into the buffer; here it is an offset. > > Not seeing it. Sorry, it was a comment assuming the simpler code in lines 1849-1851 from Raffaello. >> src/java.base/share/classes/java/lang/AbstractStringBuilder.java line 1904: >> >>> 1902: public AbstractStringBuilder repeat(CharSequence cs, int count) { >>> 1903: if (cs == null) { >>> 1904: return repeatNull(count); >> >> Or just replace `cs = "null";` and fall through to the rest. > > Same. Same, don't add more code than necessary. ------------- PR: https://git.openjdk.org/jdk/pull/12728