firstIndexOf() — netty Function Reference
Architecture documentation for the firstIndexOf() function in ByteBufUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e875d748_c115_bc76_dba9_df211beb4775["firstIndexOf()"] 920454f6_25f6_4a9b_3d32_9684c3e11f6c["ByteBufUtil"] e875d748_c115_bc76_dba9_df211beb4775 -->|defined in| 920454f6_25f6_4a9b_3d32_9684c3e11f6c dcc74aff_0a0f_d5a0_91c4_79b5b078f4f0["linearFirstIndexOf()"] e875d748_c115_bc76_dba9_df211beb4775 -->|calls| dcc74aff_0a0f_d5a0_91c4_79b5b078f4f0 d655b9ad_9dec_3bdf_40e3_78e349063353["unrolledFirstIndexOf()"] e875d748_c115_bc76_dba9_df211beb4775 -->|calls| d655b9ad_9dec_3bdf_40e3_78e349063353 style e875d748_c115_bc76_dba9_df211beb4775 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
buffer/src/main/java/io/netty/buffer/ByteBufUtil.java lines 572–610
static int firstIndexOf(AbstractByteBuf buffer, int fromIndex, int toIndex, byte value) {
fromIndex = Math.max(fromIndex, 0);
if (fromIndex >= toIndex || buffer.capacity() == 0) {
return -1;
}
final int length = toIndex - fromIndex;
buffer.checkIndex(fromIndex, length);
if (!PlatformDependent.isUnaligned()) {
return linearFirstIndexOf(buffer, fromIndex, toIndex, value);
}
assert PlatformDependent.isUnaligned();
int offset = fromIndex;
final int byteCount = length & 7;
if (byteCount > 0) {
final int index = unrolledFirstIndexOf(buffer, fromIndex, byteCount, value);
if (index != -1) {
return index;
}
offset += byteCount;
if (offset == toIndex) {
return -1;
}
}
final int longCount = length >>> 3;
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; i < longCount; i++) {
// 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) {
return offset + SWARUtil.getIndex(result, isNative);
}
offset += Long.BYTES;
}
return -1;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does firstIndexOf() do?
firstIndexOf() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java.
Where is firstIndexOf() defined?
firstIndexOf() is defined in buffer/src/main/java/io/netty/buffer/ByteBufUtil.java at line 572.
What does firstIndexOf() call?
firstIndexOf() calls 2 function(s): linearFirstIndexOf, unrolledFirstIndexOf.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free