On Thu, 23 Mar 2023 14:51:40 GMT, Sergey Tsypanov <stsypa...@openjdk.org> wrote:
>> src/java.base/share/classes/java/io/BufferedInputStream.java line 211: >> >>> 209: throw new IllegalArgumentException("Buffer size <= 0"); >>> 210: } >>> 211: buf = new byte[0]; >> >> Two recommendations: >> 1. This `new byte[0]` can be safely shared, so I recommend you to put it in >> a static final field to avoid reallocation >> 2. The subclass compatibility can be retained by: >> Suggestion: >> >> buf = (getClass() == BufferedInputStream.class) ? new byte[0] : new >> byte[size]; > > Good point, done! Btw, maybe it'd be better to rename `getBufIfOpen()` into e.g. `getBuffer()` to make it less confusing? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13150#discussion_r1146344036