Inline redundant local variables.

This commit is contained in:
Craig P. Motlin 2011-11-12 13:25:27 -05:00
parent ab61090572
commit b6dc30b37b
11 changed files with 21 additions and 43 deletions

View File

@ -804,8 +804,7 @@ public class ChannelBuffers {
} }
private static ChannelBuffer copiedBuffer(ByteOrder endianness, CharBuffer buffer, Charset charset) { private static ChannelBuffer copiedBuffer(ByteOrder endianness, CharBuffer buffer, Charset charset) {
CharBuffer src = buffer; ByteBuffer dst = ChannelBuffers.encodeString(buffer, charset);
ByteBuffer dst = ChannelBuffers.encodeString(src, charset);
ChannelBuffer result = wrappedBuffer(endianness, dst.array()); ChannelBuffer result = wrappedBuffer(endianness, dst.array());
result.writerIndex(dst.remaining()); result.writerIndex(dst.remaining());
return result; return result;

View File

@ -59,8 +59,7 @@ final class CombinedIterator<E> implements Iterator<E> {
@Override @Override
public E next() { public E next() {
try { try {
E e = currentIterator.next(); return currentIterator.next();
return e;
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
if (currentIterator == i1) { if (currentIterator == i1) {
currentIterator = i2; currentIterator = i2;

View File

@ -252,9 +252,7 @@ public class HttpTunnelMessageUtils {
} }
public static HttpResponse createTunnelCloseResponse() { public static HttpResponse createTunnelCloseResponse() {
HttpResponse response = return createResponseTemplate(HttpResponseStatus.RESET_CONTENT, null);
createResponseTemplate(HttpResponseStatus.RESET_CONTENT, null);
return response;
} }
public static boolean isTunnelCloseResponse(HttpResponse response) { public static boolean isTunnelCloseResponse(HttpResponse response) {

View File

@ -143,9 +143,7 @@ public class MixedAttribute implements Attribute {
if (buffer.readableBytes() > limitSize) { if (buffer.readableBytes() > limitSize) {
if (attribute instanceof MemoryAttribute) { if (attribute instanceof MemoryAttribute) {
// change to Disk // change to Disk
DiskAttribute diskAttribute = new DiskAttribute(attribute attribute = new DiskAttribute(attribute.getName());
.getName());
attribute = diskAttribute;
} }
} }
attribute.setContent(buffer); attribute.setContent(buffer);
@ -156,9 +154,7 @@ public class MixedAttribute implements Attribute {
if (file.length() > limitSize) { if (file.length() > limitSize) {
if (attribute instanceof MemoryAttribute) { if (attribute instanceof MemoryAttribute) {
// change to Disk // change to Disk
DiskAttribute diskAttribute = new DiskAttribute(attribute attribute = new DiskAttribute(attribute.getName());
.getName());
attribute = diskAttribute;
} }
} }
attribute.setContent(file); attribute.setContent(file);
@ -168,9 +164,7 @@ public class MixedAttribute implements Attribute {
public void setContent(InputStream inputStream) throws IOException { public void setContent(InputStream inputStream) throws IOException {
if (attribute instanceof MemoryAttribute) { if (attribute instanceof MemoryAttribute) {
// change to Disk even if we don't know the size // change to Disk even if we don't know the size
DiskAttribute diskAttribute = new DiskAttribute(attribute attribute = new DiskAttribute(attribute.getName());
.getName());
attribute = diskAttribute;
} }
attribute.setContent(inputStream); attribute.setContent(inputStream);
} }

View File

@ -147,12 +147,11 @@ public class MixedFileUpload implements FileUpload {
if (buffer.readableBytes() > limitSize) { if (buffer.readableBytes() > limitSize) {
if (fileUpload instanceof MemoryFileUpload) { if (fileUpload instanceof MemoryFileUpload) {
// change to Disk // change to Disk
DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload fileUpload = new DiskFileUpload(fileUpload
.getName(), fileUpload.getFilename(), fileUpload .getName(), fileUpload.getFilename(), fileUpload
.getContentType(), fileUpload .getContentType(), fileUpload
.getContentTransferEncoding(), fileUpload.getCharset(), .getContentTransferEncoding(), fileUpload.getCharset(),
definedSize); definedSize);
fileUpload = diskFileUpload;
} }
} }
fileUpload.setContent(buffer); fileUpload.setContent(buffer);
@ -163,12 +162,11 @@ public class MixedFileUpload implements FileUpload {
if (file.length() > limitSize) { if (file.length() > limitSize) {
if (fileUpload instanceof MemoryFileUpload) { if (fileUpload instanceof MemoryFileUpload) {
// change to Disk // change to Disk
DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload fileUpload = new DiskFileUpload(fileUpload
.getName(), fileUpload.getFilename(), fileUpload .getName(), fileUpload.getFilename(), fileUpload
.getContentType(), fileUpload .getContentType(), fileUpload
.getContentTransferEncoding(), fileUpload.getCharset(), .getContentTransferEncoding(), fileUpload.getCharset(),
definedSize); definedSize);
fileUpload = diskFileUpload;
} }
} }
fileUpload.setContent(file); fileUpload.setContent(file);
@ -178,12 +176,11 @@ public class MixedFileUpload implements FileUpload {
public void setContent(InputStream inputStream) throws IOException { public void setContent(InputStream inputStream) throws IOException {
if (fileUpload instanceof MemoryFileUpload) { if (fileUpload instanceof MemoryFileUpload) {
// change to Disk // change to Disk
DiskFileUpload diskFileUpload = new DiskFileUpload(fileUpload fileUpload = new DiskFileUpload(fileUpload
.getName(), fileUpload.getFilename(), fileUpload .getName(), fileUpload.getFilename(), fileUpload
.getContentType(), fileUpload .getContentType(), fileUpload
.getContentTransferEncoding(), fileUpload.getCharset(), .getContentTransferEncoding(), fileUpload.getCharset(),
definedSize); definedSize);
fileUpload = diskFileUpload;
} }
fileUpload.setContent(inputStream); fileUpload.setContent(inputStream);
} }

View File

@ -204,7 +204,6 @@ public abstract class WebSocketClientHandshaker {
* @return Random number * @return Random number
*/ */
protected int createRandomNumber(int min, int max) { protected int createRandomNumber(int min, int max) {
int rand = (int) (Math.random() * max + min); return (int) (Math.random() * max + min);
return rand;
} }
} }

View File

@ -98,8 +98,7 @@ public class CompatibleObjectEncoder extends OneToOneEncoder {
oout.writeObject(msg); oout.writeObject(msg);
oout.flush(); oout.flush();
ChannelBuffer encoded = buffer.readBytes(buffer.readableBytes()); return buffer.readBytes(buffer.readableBytes());
return encoded;
} }
private ChannelBuffer buffer(ChannelHandlerContext ctx) throws Exception { private ChannelBuffer buffer(ChannelHandlerContext ctx) throws Exception {

View File

@ -66,8 +66,7 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler,
{ {
if (listener == null) if (listener == null)
return null; return null;
ChannelFuture result = listener.refused(ctx, e, inetSocketAddress); return listener.refused(ctx, e, inetSocketAddress);
return result;
} }
protected ChannelFuture handleAllowedChannel(ChannelHandlerContext ctx, ChannelEvent e, protected ChannelFuture handleAllowedChannel(ChannelHandlerContext ctx, ChannelEvent e,
@ -75,8 +74,7 @@ public abstract class IpFilteringHandlerImpl implements ChannelUpstreamHandler,
{ {
if (listener == null) if (listener == null)
return null; return null;
ChannelFuture result = listener.allowed(ctx, e, inetSocketAddress); return listener.allowed(ctx, e, inetSocketAddress);
return result;
} }
/** /**

View File

@ -385,8 +385,7 @@ public abstract class AbstractTrafficShapingHandler extends
// Time is too short, so just lets continue // Time is too short, so just lets continue
return 0; return 0;
} }
long wait = bytes * 1000 / limit - interval; return bytes * 1000 / limit - interval;
return wait;
} }
@Override @Override

View File

@ -519,18 +519,16 @@ final class Deflate {
} }
private void send_bits(int value, int length) { private void send_bits(int value, int length) {
int len = length; if (bi_valid > Buf_size - length) {
if (bi_valid > Buf_size - len) {
int val = value;
// bi_buf |= (val << bi_valid); // bi_buf |= (val << bi_valid);
bi_buf |= val << bi_valid & 0xffff; bi_buf |= value << bi_valid & 0xffff;
put_short(bi_buf); put_short(bi_buf);
bi_buf = (short) (val >>> Buf_size - bi_valid); bi_buf = (short) (value >>> Buf_size - bi_valid);
bi_valid += len - Buf_size; bi_valid += length - Buf_size;
} else { } else {
// bi_buf |= (value) << bi_valid; // bi_buf |= (value) << bi_valid;
bi_buf |= value << bi_valid & 0xffff; bi_buf |= value << bi_valid & 0xffff;
bi_valid += len; bi_valid += length;
} }
} }

View File

@ -83,9 +83,8 @@ public class HttpTunnelServerChannelSinkTest {
} }
}); });
ChannelFuture virtualFuture1 = Channels.close(channel); ChannelFuture virtualFuture = Channels.close(channel);
mockContext.assertIsSatisfied(); mockContext.assertIsSatisfied();
ChannelFuture virtualFuture = virtualFuture1;
realFuture.setSuccess(); realFuture.setSuccess();
assertTrue(virtualFuture.isSuccess()); assertTrue(virtualFuture.isSuccess());
} }
@ -140,8 +139,7 @@ public class HttpTunnelServerChannelSinkTest {
} }
}); });
ChannelFuture virtualFuture = Channels.bind(channel, toAddress); return Channels.bind(channel, toAddress);
return virtualFuture;
} }
private final class ExceptionCatcher extends SimpleChannelUpstreamHandler { private final class ExceptionCatcher extends SimpleChannelUpstreamHandler {