Sample

int-58b39e8d030e-SRC

Unmodified source class

Lines133

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.5090–1; higher is more readable
Dorn0.3080–1; higher is more readable
Mi0.3050–1; higher is more readable
LLOC84Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4150–1; higher is more readable

Views

Source code

package io.netty.handler.codec.quic; import io.netty.util.internal.ObjectUtil; import java.nio.ByteBuffer; import java.nio.ByteOrder; /** * <a href="https://www.aumasson.jp/siphash/siphash.pdf">Siphash implementation</a>. */ final class SipHash { static final int SEED_LENGTH = 16; // Make this class allocation free as soon as its constructed. private final int compressionRounds; private final int finalizationRounds; // As specified in https://www.aumasson.jp/siphash/siphash.pdf private static final long INITIAL_STATE_V0 = 0x736f6d6570736575L; // "somepseu" private static final long INITIAL_STATE_V1 = 0x646f72616e646f6dL; // "dorandom" private static final long INITIAL_STATE_V2 = 0x6c7967656e657261L; // "lygenera" private static final long INITIAL_STATE_V3 = 0x7465646279746573L; // "tedbytes" private final long initialStateV0; private final long initialStateV1; private final long initialStateV2; private final long initialStateV3; private long v0; private long v1; private long v2; private long v3; SipHash(int compressionRounds, int finalizationRounds, byte[] seed) { if (seed.length != SEED_LENGTH) { throw new IllegalArgumentException("seed must be of length " + SEED_LENGTH); } this.compressionRounds = ObjectUtil.checkPositive(compressionRounds, "compressionRounds"); this.finalizationRounds = ObjectUtil.checkPositive(finalizationRounds, "finalizationRounds"); // Wrap the seed to extract two longs that will be used to generate the initial state. // Use little-endian as in the paper. ByteBuffer keyBuffer = ByteBuffer.wrap(seed).order(ByteOrder.LITTLE_ENDIAN); final long k0 = keyBuffer.getLong(); final long k1 = keyBuffer.getLong(); initialStateV0 = INITIAL_STATE_V0 ^ k0; initialStateV1 = INITIAL_STATE_V1 ^ k1; initialStateV2 = INITIAL_STATE_V2 ^ k0; initialStateV3 = INITIAL_STATE_V3 ^ k1; } long macHash(ByteBuffer input) { v0 = initialStateV0; v1 = initialStateV1; v2 = initialStateV2; v3 = initialStateV3; int remaining = input.remaining(); int position = input.position(); int len = remaining - (remaining % Long.BYTES); boolean needsReverse = input.order() == ByteOrder.BIG_ENDIAN; for (int offset = position; offset < len; offset += Long.BYTES) { long m = input.getLong(offset); if (needsReverse) { // We use little-endian as in the paper. m = Long.reverseBytes(m); } v3 ^= m; for (int i = 0; i < compressionRounds; i++) { sipround(); } v0 ^= m; } // Get last bits. final int left = remaining & (Long.BYTES - 1); long b = (long) remaining << 56; assert left < Long.BYTES; switch (left) { case 7: b |= (long) input.get(position + len + 6) << 48; case 6: b |= (long) input.get(position + len + 5) << 40; case 5: b |= (long) input.get(position + len + 4) << 32; case 4: b |= (long) input.get(position + len + 3) << 24; case 3: b |= (long) input.get(position + len + 2) << 16; case 2: b |= (long) input.get(position + len + 1) << 8; case 1: b |= input.get(position + len); break; case 0: break; default: throw new IllegalStateException("Unexpected value: " + left); } v3 ^= b; for (int i = 0; i < compressionRounds; i++) { sipround(); } v0 ^= b; v2 ^= 0xFF; for (int i = 0; i < finalizationRounds; i++) { sipround(); } return v0 ^ v1 ^ v2 ^ v3; } private void sipround() { v0 += v1; v2 += v3; v1 = Long.rotateLeft(v1, 13); v3 = Long.rotateLeft(v3, 16); v1 ^= v0; v3 ^= v2; v0 = Long.rotateLeft(v0, 32); v2 += v1; v0 += v3; v1 = Long.rotateLeft(v1, 17); v3 = Long.rotateLeft(v3, 21); v1 ^= v2; v3 ^= v0; v2 = Long.rotateLeft(v2, 32); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.5373.21−177.316
Source linesThe number of non-empty source lines.133+53.2
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.646−6.969

Intercept 8.87 + feature contributions = -122.215 (log-odds).
Score = sigmoid(-122.215) = 0.

Score0.509

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.134−3.708
Indentation frequencyHow rapidly indentation changes from line to line.121+3.448
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.121−2.356
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.132.892+1.448
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.100.948+0.824
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.100.978−0.612
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.089+0.074

Intercept 0.07 + feature contributions = -0.811 (log-odds).
Score = sigmoid(-0.811) = 0.308.

Score0.305
Score84
Run 1

The code is generally well-structured, with clear naming, constants, and logical separation of initialization, hashing, and round logic. The constructor validates inputs and sets up state cleanly. The sipround() method is concise and follows the algorithm directly. However, the macHash method has moderate complexity: the final partial-block switch statement uses fall-through cases, which can be harder to read, and offset calculations like `position + len + 6` reduce clarity. The loop is flat but involves multiple responsibilities (endianness handling, state update). Overall, the code is readable but could be improved with a helper method for reading the final bytes and a clearer comment for the fall-through logic.

Run 2

The code is well-structured with logical separation of constants, state initialization, and hashing logic. Nesting is shallow, and action granularity is generally one operation per line, aiding readability. The intent is clear through method names and comments, though the fall-through switch cases and bit manipulation require domain knowledge. The switch statement would appear to fall-through without comments, potentially reducing clarity. Code length is concise, and reading flow is natural with helper methods. Deductions come from the non-obvious fall-through pattern and complex cryptographic operations that could benefit from additional inline comments.

Run 3

The code is generally well-structured and readable. It uses clear variable names, helpful comments, and separates concerns logically (state initialization, hash computation, round function). The algorithm follows the reference specification, which aids understanding. However, there are areas for improvement: the switch statement for tail-byte processing is somewhat dense and uses fall-through cases, which can be hard to follow. The macHash method mixes initialization, main loop, tail handling, and finalization in one method, increasing cognitive load. A few extra helper methods or clearer section comments would improve readability. Overall, it is competent and maintainable but not exemplary in clarity.

Run 1

Code Structure: Well organized into constants, state fields, initialization, hashing, and a dedicated round method. Nesting: Mostly shallow, with manageable nested loops and a conditional. Clarity of intent: Descriptive configuration names, specification links, and endian comments explain the purpose, but terse variables and unexplained rotation constants require algorithm knowledge. The switch's intentional fall-through is not documented, and the relationship between position, len, and offset is difficult to follow. Code length: Reasonably concise for a low-level hashing implementation, though repeated round loops and state assignments add some repetition. Action granularity: Almost every statement performs one operation, making state changes easy to track. Reading flow: Initialization, block processing, tail handling, and finalization follow a natural sequence; however, the lengthy fall-through switch and mutable instance state increase the reader's tracking burden.

Run 2

Code Structure: Constants, initialization, hashing, and round operations are logically separated, though mutable instance state makes data dependencies less explicit. Nesting: Mostly shallow, with only a conditional and round loop inside the block-processing loop. Clarity of intent: Descriptive configuration names, comments, and the specification link explain the purpose; terse state variables, cryptographic constants, and undocumented switch fall-through require specialized knowledge. The distinction between absolute positions and relative lengths is not immediately clear. Code length: Reasonably concise for the algorithm, although tail-byte assembly is repetitive. Action granularity: Statements generally perform one operation per line, making state changes easy to trace. Reading flow: Initialization, block processing, tail handling, and finalization follow a natural sequence; additional phase labels and fall-through comments would improve readability.

Run 3

Code Structure: Well organized into initialization, hashing, and a dedicated round function, with named constants separating configuration from state. Nesting: Mostly shallow; the block-processing loop contains only a conditional and a round loop. Clarity of intent: Descriptive configuration names and specification references help, but terse state variables, unexplained rotation constants, and undocumented switch fall-through require algorithm knowledge. The relationship between position, remaining, and len is also difficult to follow. Code length: Reasonably concise for a cryptographic implementation, though tail-byte handling is repetitive. Action granularity: Almost every line performs one operation, making state updates easy to inspect. Reading flow: Initialization, block processing, tail handling, and finalization follow a natural sequence, with whitespace grouping round operations. More explicit phase comments and clarification of fall-through and offset calculations would improve readability.