On Mon, 4 Dec 2023 17:11:58 GMT, Chen Liang <[email protected]> wrote:
>> This improvement has been found on >> https://github.com/vert-x3/vertx-web/pull/2526. >> >> It can potentially affect the existing ArraysSupport.mismatch caller >> code-path performance ie requires investigation. > > src/java.base/share/classes/java/lang/String.java line 2185: > >> 2183: byte[] ov = other.value; >> 2184: if (coder == otherCoder) { >> 2185: if ((ooffset | toffset) == 0 && len == (tv.length >> >> coder) && ov.length == tv.length) { > > Just curious, is `(ooffset | toffset) == 0` more efficient than `ooffset == 0 > && toffset== 0`? It can be, depending the probability of happening for both and if/where their caller is inlined (presenting itself into different addresses, basically): conditions easy to predict are very cheap, but if not, can have some performance penalties. An `|` between register is super cheap, instead: the same tecnique has been used at https://github.com/openjdk/jdk/blob/a26f7c03c72e4efe6d3219d294294c554aebc631/src/hotspot/share/utilities/copy.cpp#L215 which is supposed to be another hot-path, probably for similar reasons. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16933#discussion_r1414227453
