Remove pointless bitwise expressions

This commit is contained in:
Trustin Lee 2012-11-09 17:26:11 +09:00
parent 57aa842b63
commit 2ab38d8685
4 changed files with 16 additions and 16 deletions

View File

@ -33,8 +33,8 @@ public final class ByteBufUtil {
static { static {
final char[] DIGITS = "0123456789abcdef".toCharArray(); final char[] DIGITS = "0123456789abcdef".toCharArray();
for (int i = 0; i < 256; i ++) { for (int i = 0; i < 256; i ++) {
HEXDUMP_TABLE[(i << 1) + 0] = DIGITS[i >>> 4 & 0x0F]; HEXDUMP_TABLE[ i << 1 ] = DIGITS[i >>> 4 & 0x0F];
HEXDUMP_TABLE[(i << 1) + 1] = DIGITS[i >>> 0 & 0x0F]; HEXDUMP_TABLE[(i << 1) + 1] = DIGITS[i & 0x0F];
} }
} }

View File

@ -15,6 +15,8 @@
*/ */
package io.netty.buffer; package io.netty.buffer;
import sun.misc.Cleaner;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -25,8 +27,6 @@ import java.nio.channels.ClosedChannelException;
import java.nio.channels.GatheringByteChannel; import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel; import java.nio.channels.ScatteringByteChannel;
import sun.misc.Cleaner;
/** /**
* A NIO {@link ByteBuffer} based buffer. It is recommended to use {@link Unpooled#directBuffer(int)} * A NIO {@link ByteBuffer} based buffer. It is recommended to use {@link Unpooled#directBuffer(int)}
* and {@link Unpooled#wrappedBuffer(ByteBuffer)} instead of calling the * and {@link Unpooled#wrappedBuffer(ByteBuffer)} instead of calling the
@ -208,8 +208,7 @@ public class DirectByteBuf extends AbstractByteBuf {
@Override @Override
public int getUnsignedMedium(int index) { public int getUnsignedMedium(int index) {
return (getByte(index) & 0xff) << 16 | (getByte(index + 1) & 0xff) << 8 | return (getByte(index) & 0xff) << 16 | (getByte(index + 1) & 0xff) << 8 | getByte(index + 2) & 0xff;
(getByte(index + 2) & 0xff) << 0;
} }
@Override @Override
@ -278,7 +277,7 @@ public class DirectByteBuf extends AbstractByteBuf {
public ByteBuf setMedium(int index, int value) { public ByteBuf setMedium(int index, int value) {
setByte(index, (byte) (value >>> 16)); setByte(index, (byte) (value >>> 16));
setByte(index + 1, (byte) (value >>> 8)); setByte(index + 1, (byte) (value >>> 8));
setByte(index + 2, (byte) (value >>> 0)); setByte(index + 2, (byte) value);
return this; return this;
} }

View File

@ -237,7 +237,7 @@ public class HeapByteBuf extends AbstractByteBuf {
public int getUnsignedMedium(int index) { public int getUnsignedMedium(int index) {
return (array[index] & 0xff) << 16 | return (array[index] & 0xff) << 16 |
(array[index + 1] & 0xff) << 8 | (array[index + 1] & 0xff) << 8 |
(array[index + 2] & 0xff) << 0; array[index + 2] & 0xff;
} }
@Override @Override
@ -245,7 +245,7 @@ public class HeapByteBuf extends AbstractByteBuf {
return (array[index] & 0xff) << 24 | return (array[index] & 0xff) << 24 |
(array[index + 1] & 0xff) << 16 | (array[index + 1] & 0xff) << 16 |
(array[index + 2] & 0xff) << 8 | (array[index + 2] & 0xff) << 8 |
(array[index + 3] & 0xff) << 0; array[index + 3] & 0xff;
} }
@Override @Override
@ -257,13 +257,13 @@ public class HeapByteBuf extends AbstractByteBuf {
((long) array[index + 4] & 0xff) << 24 | ((long) array[index + 4] & 0xff) << 24 |
((long) array[index + 5] & 0xff) << 16 | ((long) array[index + 5] & 0xff) << 16 |
((long) array[index + 6] & 0xff) << 8 | ((long) array[index + 6] & 0xff) << 8 |
((long) array[index + 7] & 0xff) << 0; (long) array[index + 7] & 0xff;
} }
@Override @Override
public ByteBuf setShort(int index, int value) { public ByteBuf setShort(int index, int value) {
array[index] = (byte) (value >>> 8); array[index] = (byte) (value >>> 8);
array[index + 1] = (byte) (value >>> 0); array[index + 1] = (byte) value;
return this; return this;
} }
@ -271,7 +271,7 @@ public class HeapByteBuf extends AbstractByteBuf {
public ByteBuf setMedium(int index, int value) { public ByteBuf setMedium(int index, int value) {
array[index] = (byte) (value >>> 16); array[index] = (byte) (value >>> 16);
array[index + 1] = (byte) (value >>> 8); array[index + 1] = (byte) (value >>> 8);
array[index + 2] = (byte) (value >>> 0); array[index + 2] = (byte) value;
return this; return this;
} }
@ -280,7 +280,7 @@ public class HeapByteBuf extends AbstractByteBuf {
array[index] = (byte) (value >>> 24); array[index] = (byte) (value >>> 24);
array[index + 1] = (byte) (value >>> 16); array[index + 1] = (byte) (value >>> 16);
array[index + 2] = (byte) (value >>> 8); array[index + 2] = (byte) (value >>> 8);
array[index + 3] = (byte) (value >>> 0); array[index + 3] = (byte) value;
return this; return this;
} }
@ -293,7 +293,7 @@ public class HeapByteBuf extends AbstractByteBuf {
array[index + 4] = (byte) (value >>> 24); array[index + 4] = (byte) (value >>> 24);
array[index + 5] = (byte) (value >>> 16); array[index + 5] = (byte) (value >>> 16);
array[index + 6] = (byte) (value >>> 8); array[index + 6] = (byte) (value >>> 8);
array[index + 7] = (byte) (value >>> 0); array[index + 7] = (byte) value;
return this; return this;
} }

View File

@ -15,7 +15,6 @@
*/ */
package io.netty.handler.codec.spdy; package io.netty.handler.codec.spdy;
import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
@ -27,6 +26,8 @@ import io.netty.util.CharsetUtil;
import java.util.Set; import java.util.Set;
import static io.netty.handler.codec.spdy.SpdyCodecUtil.*;
/** /**
* Encodes a SPDY Data or Control Frame into a {@link ByteBuf}. * Encodes a SPDY Data or Control Frame into a {@link ByteBuf}.
*/ */
@ -192,7 +193,7 @@ public class SpdyFrameEncoder extends MessageToByteEncoder<Object> {
// Chromium Issue 79156 // Chromium Issue 79156
// SPDY setting ids are not written in network byte order // SPDY setting ids are not written in network byte order
// Write id assuming the architecture is little endian // Write id assuming the architecture is little endian
out.writeByte(id >> 0 & 0xFF); out.writeByte(id & 0xFF);
out.writeByte(id >> 8 & 0xFF); out.writeByte(id >> 8 & 0xFF);
out.writeByte(id >> 16 & 0xFF); out.writeByte(id >> 16 & 0xFF);
out.writeByte(ID_flags); out.writeByte(ID_flags);