On Fri, 6 Sep 2024 15:11:19 GMT, Brett Okken <d...@openjdk.org> wrote:
>> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Fix errors in a benchmark > > src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java > line 244: > >> 242: return (Architecture.isLittleEndian() >> 243: ? Long.numberOfTrailingZeros(x) >> 244: : Long.numberOfLeadingZeros(x)) / 8; > > Would there be value in having a constant LongToIntFunction lambda to capture > this logic? > > > private static final LongToIntFunction LONG_LEADING_ZEROS = > Architecture.isLittleEndian() ? Long::numberOfTrailingZeros : > Long::numberOfLeadingZeros; Performance-wise, I suspect there would not be that much of a difference. The compiler will see that Architecture.isLittleEndian provides a stable value and can optimize and eliminate code (I think). I am unsure which is easier to read. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20848#discussion_r1754496696