On Wed, 18 Jan 2023 16:34:57 GMT, Per Minborg <[email protected]> wrote:
> This PR proposes using a performance optimization using a new supported API
> for operations similar to those found in `java.io.Bits`
Some comments:
src/java.base/share/classes/jdk/internal/util/Bits.java line 43:
> 41: }
> 42:
> 43: public static final class BigEndian {
Are there other names that improve the readability of the uses?
For example `ByteArray.getShort()` and `ByteArray.getDouble`.
There's been a move to drop `get` and `put` prefixes where they are unnecessary.
Get and put prefixes do make them similar to the existing methods, but...
Is it just a readable to say:
`float degrees = ByteArray.float(buf);` // for get
`ByteArray.int(buf, degrees);` // for put
Maybe, maybe not....
src/java.base/share/classes/jdk/internal/util/Bits.java line 161:
> 159: }
> 160:
> 161: public static final class BigEndianAtZero {
I'd merge these methods (with zero offset) in with the previous class; the
overloads with offsets are sufficient to distinguish them and it would make
discovery more natural. (omitting this class).
src/java.base/share/classes/jdk/internal/util/Bits.java line 284:
> 282:
> 283: // Alternative with an internal buffer fixed att offset zero.
> 284: public static final class BigEndianAtZeroBuffer {
I'd keep it simple an leave the buffer management to the caller. (Omitting this
class).
-------------
PR: https://git.openjdk.org/jdk/pull/12076