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

Code Improvements: remove reduntant cast, add static to private functions #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/MemcachedConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ protected void queueReconnect(final MemcachedNode node) {
*
* @param ops the list of operations to cancel.
*/
private void cancelOperations(final Collection<Operation> ops) {
private static void cancelOperations(final Collection<Operation> ops) {
for (Operation op : ops) {
op.cancel();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/TapClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void complete() {
return ts;
}

private void tapAck(TapConnectionProvider conn, MemcachedNode node,
private static void tapAck(TapConnectionProvider conn, MemcachedNode node,
TapOpcode opcode, int opaque, OperationCallback cb) {
final Operation op = conn.getOpFactory().tapAck(opcode, opaque, cb);
conn.addTapAckOp(node, op);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public abstract class BaseOperationFactory implements OperationFactory {

private String first(Collection<String> keys) {
private static String first(Collection<String> keys) {
return keys.iterator().next();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public String toString() {
protected void decodePayload(byte[] pl) {
final short keylen = (short) decodeShort(pl, 2);
keystate = (byte) decodeByte(pl, keylen+4);
retCas = (long) decodeLong(pl, keylen+5);
retCas = decodeLong(pl, keylen+5);
ObserveResponse r = ObserveResponse.valueOf(keystate);
((ObserveOperation.Callback) getCallback()).gotData(key, retCas,
getHandlingNode(), r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private Short decodeShort(byte[] data) {
return Short.valueOf((short) decodeInteger(data).intValue());
}

private Byte decodeByte(byte[] in) {
private static Byte decodeByte(byte[] in) {
assert in.length == 2 : "Wrong length for a byte";
byte value = in[1];
return Byte.valueOf(value);
Expand All @@ -190,12 +190,12 @@ private Double decodeDouble(byte[] in) {
return Double.valueOf(Double.longBitsToDouble(l.longValue()));
}

private Boolean decodeBoolean(byte[] in) {
private static Boolean decodeBoolean(byte[] in) {
assert in.length == 2 : "Wrong length for a boolean";
return Boolean.valueOf(in[1] == 1);
}

private Long decodeLong(byte[] in) {
private static Long decodeLong(byte[] in) {
long rv = 0L;
for (int idx = 1; idx < in.length; idx++) {
byte i = in[idx];
Expand All @@ -216,14 +216,14 @@ private String decodeW1String(byte[] b) {
}
}

private byte[] encodeByte(Byte value) {
private static byte[] encodeByte(Byte value) {
byte[] b = new byte[2];
b[0] = SPECIAL_BYTE;
b[1] = value.byteValue();
return b;
}

private byte[] encodeBoolean(Boolean value) {
private static byte[] encodeBoolean(Boolean value) {
byte[] b = new byte[2];
b[0] = SPECIAL_BOOLEAN;
b[1] = (byte) (value.booleanValue() ? 1 : 0);
Expand Down Expand Up @@ -295,7 +295,7 @@ private byte[] encodeW1String(String value) {
return result;
}

private byte[] encodeNum(long l, int maxBytes) {
private static byte[] encodeNum(long l, int maxBytes) {
byte[] rv = new byte[maxBytes + 1];

for (int i = 0; i < rv.length - 1; i++) {
Expand Down