lastIndexOf() — netty Function Reference
Architecture documentation for the lastIndexOf() function in ByteBufUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e9312b0e_c5cc_d3d1_73a9_ba37fd8c6bb4["lastIndexOf()"] 920454f6_25f6_4a9b_3d32_9684c3e11f6c["ByteBufUtil"] e9312b0e_c5cc_d3d1_73a9_ba37fd8c6bb4 -->|defined in| 920454f6_25f6_4a9b_3d32_9684c3e11f6c d11f1706_dd2f_a5f2_9233_cb78ffafb90a["linearLastIndexOf()"] e9312b0e_c5cc_d3d1_73a9_ba37fd8c6bb4 -->|calls| d11f1706_dd2f_a5f2_9233_cb78ffafb90a eec154fb_8b13_48f3_3735_b609819320b4["unrolledLastIndexOf()"] e9312b0e_c5cc_d3d1_73a9_ba37fd8c6bb4 -->|calls| eec154fb_8b13_48f3_3735_b609819320b4 style e9312b0e_c5cc_d3d1_73a9_ba37fd8c6bb4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/ByteBufUtil.java lines 723–752
static int lastIndexOf(final AbstractByteBuf buffer, int fromIndex, final int toIndex, final byte value) {
assert fromIndex > toIndex;
final int capacity = buffer.capacity();
fromIndex = Math.min(fromIndex, capacity);
if (fromIndex <= 0) { // fromIndex is the exclusive upper bound.
return -1;
}
final int length = fromIndex - toIndex;
buffer.checkIndex(toIndex, length);
if (!PlatformDependent.isUnaligned()) {
return linearLastIndexOf(buffer, fromIndex, toIndex, value);
}
final int longCount = length >>> 3;
if (longCount > 0) {
final ByteOrder nativeOrder = ByteOrder.nativeOrder();
final boolean isNative = nativeOrder == buffer.order();
final boolean useLE = nativeOrder == ByteOrder.LITTLE_ENDIAN;
final long pattern = SWARUtil.compilePattern(value);
for (int i = 0, offset = fromIndex - Long.BYTES; i < longCount; i++, offset -= Long.BYTES) {
// use the faster available getLong
final long word = useLE? buffer._getLongLE(offset) : buffer._getLong(offset);
final long result = SWARUtil.applyPattern(word, pattern);
if (result != 0) {
// used the oppoiste endianness since we are looking for the last index.
return offset + Long.BYTES - 1 - SWARUtil.getIndex(result, !isNative);
}
}
}
return unrolledLastIndexOf(buffer, fromIndex - (longCount << 3), length & 7, value);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does lastIndexOf() do?
lastIndexOf() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java.
Where is lastIndexOf() defined?
lastIndexOf() is defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java at line 723.
What does lastIndexOf() call?
lastIndexOf() calls 2 function(s): linearLastIndexOf, unrolledLastIndexOf.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free