Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline variables to make code more readable #11565

Merged
merged 2 commits into from Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1278,8 +1278,7 @@ private static void mockFlowControl(Http2FrameListener listener) throws Http2Exc
public Integer answer(InvocationOnMock invocation) throws Throwable {
ByteBuf buf = (ByteBuf) invocation.getArguments()[2];
int padding = (Integer) invocation.getArguments()[3];
int processedBytes = buf.readableBytes() + padding;
return processedBytes;
return buf.readableBytes() + padding;
}

}).when(listener).onDataRead(any(ChannelHandlerContext.class), anyInt(),
Expand Down
Expand Up @@ -301,17 +301,16 @@ public void lowestPrecedenceStateShouldBeDropped() throws Http2Exception {
// Stream 3 (hasn't been opened) should result in stream 5 being dropped.
// dropping stream 5 will distribute its weight to children (only 9)
setPriority(3, 9, weight3, false);
short newWeight9 = weight5;
verifyLowestPrecedenceStateShouldBeDropped3(weight3, weight7, newWeight9);
verifyLowestPrecedenceStateShouldBeDropped3(weight3, weight7, weight5);

// Stream 5's state has been discarded so we should be able to re-insert this state.
setPriority(5, 0, weight5, false);
verifyLowestPrecedenceStateShouldBeDropped4(weight5, weight7, newWeight9);
verifyLowestPrecedenceStateShouldBeDropped4(weight5, weight7, weight5);

// All streams are at the same level, so stream ID should be used to drop the numeric lowest valued stream.
short weight11 = (short) (weight9 - 1);
setPriority(11, 0, weight11, false);
verifyLowestPrecedenceStateShouldBeDropped5(weight7, newWeight9, weight11);
verifyLowestPrecedenceStateShouldBeDropped5(weight7, weight5, weight11);
}

private void verifyLowestPrecedenceStateShouldBeDropped1(short weight3, short weight5, short weight7) {
Expand Down
Expand Up @@ -341,7 +341,6 @@ private void writeBlockData(ByteBuf out) {
final Bzip2BitWriter writer = this.writer;
final int[][] huffmanMergedCodeSymbols = this.huffmanMergedCodeSymbols;
final byte[] selectors = this.selectors;
final char[] mtf = mtfBlock;
final int mtfLength = this.mtfLength;

int selectorIndex = 0;
Expand All @@ -350,7 +349,7 @@ private void writeBlockData(ByteBuf out) {
final int[] tableMergedCodeSymbols = huffmanMergedCodeSymbols[selectors[selectorIndex++]];

while (mtfIndex <= groupEnd) {
final int mergedCodeSymbol = tableMergedCodeSymbols[mtf[mtfIndex++]];
final int mergedCodeSymbol = tableMergedCodeSymbols[mtfBlock[mtfIndex++]];
writer.writeBits(out, mergedCodeSymbol >>> 24, mergedCodeSymbol);
}
}
Expand Down
Expand Up @@ -49,9 +49,8 @@ public ResourceLeakException(Throwable cause) {

@Override
public int hashCode() {
StackTraceElement[] trace = cachedStackTrace;
int hashCode = 0;
for (StackTraceElement e: trace) {
for (StackTraceElement e: cachedStackTrace) {
hashCode = hashCode * 31 + e.hashCode();
}
return hashCode;
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/java/io/netty/util/internal/StringUtil.java
Expand Up @@ -243,8 +243,7 @@ public static int decodeHexNibble(final char c) {
assert HEX2B.length == (Character.MAX_VALUE + 1);
// Character.digit() is not used here, as it addresses a larger
// set of characters (both ASCII and full-width latin letters).
final int index = c;
return HEX2B[index];
return HEX2B[c];
}

/**
Expand Down
Expand Up @@ -175,15 +175,13 @@ public void execute() {
@Test
public void escapeCsvEmpty() {
CharSequence value = "";
CharSequence expected = value;
escapeCsv(value, expected);
escapeCsv(value, value);
}

@Test
public void escapeCsvUnquoted() {
CharSequence value = "something";
CharSequence expected = value;
escapeCsv(value, expected);
escapeCsv(value, value);
}

@Test
Expand Down Expand Up @@ -259,8 +257,7 @@ public void escapeCsvAlreadyEscapedQuote() {
@Test
public void escapeCsvQuoted() {
CharSequence value = "\"foo,goo\"";
CharSequence expected = value;
escapeCsv(value, expected);
escapeCsv(value, value);
}

@Test
Expand Down
Expand Up @@ -165,14 +165,13 @@ private static int decodeHexNibble(final char c) {
}

private static int decodeHexNibbleWithCheck(final char c) {
final int index = c;
if (index >= HEX2B.length) {
if ((int) c >= HEX2B.length) {
return -1;
}
if (PlatformDependent.hasUnsafe()) {
return PlatformDependent.getByte(HEX2B, index);
return PlatformDependent.getByte(HEX2B, c);
}
return HEX2B[index];
return HEX2B[c];
}

}
Expand Up @@ -207,10 +207,7 @@ public String toString() {
}

public List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> domainSocket() {

List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> list =
combo(serverDomainSocket(), clientDomainSocket());
return list;
return combo(serverDomainSocket(), clientDomainSocket());
}

public List<BootstrapFactory<ServerBootstrap>> serverDomainSocket() {
Expand Down
Expand Up @@ -136,9 +136,7 @@ public Bootstrap newInstance() {

public List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> domainSocket() {

List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> list =
combo(serverDomainSocket(), clientDomainSocket());
return list;
return combo(serverDomainSocket(), clientDomainSocket());
}

public List<BootstrapFactory<ServerBootstrap>> serverDomainSocket() {
Expand Down