Eliminate some unnecessary byte copy / convertion
This commit is contained in:
parent
143ba76176
commit
2b32c3fb59
@ -22,16 +22,16 @@ import java.io.IOException;
|
|||||||
public class ErrorReply extends Reply {
|
public class ErrorReply extends Reply {
|
||||||
public static final char MARKER = '-';
|
public static final char MARKER = '-';
|
||||||
private static final byte[] ERR = "ERR ".getBytes();
|
private static final byte[] ERR = "ERR ".getBytes();
|
||||||
public final String error;
|
public final ChannelBuffer error;
|
||||||
|
|
||||||
public ErrorReply(String error) {
|
public ErrorReply(ChannelBuffer error) {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(ChannelBuffer os) throws IOException {
|
public void write(ChannelBuffer os) throws IOException {
|
||||||
os.writeByte(MARKER);
|
os.writeByte(MARKER);
|
||||||
os.writeBytes(ERR);
|
os.writeBytes(ERR);
|
||||||
os.writeBytes(error.getBytes("UTF-8"));
|
os.writeBytes(error);
|
||||||
os.writeBytes(Command.CRLF);
|
os.writeBytes(Command.CRLF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,12 +92,12 @@ public class RedisDecoder extends ReplayingDecoder<State> {
|
|||||||
int code = is.readByte();
|
int code = is.readByte();
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case StatusReply.MARKER: {
|
case StatusReply.MARKER: {
|
||||||
String status = is.readBytes(is.bytesBefore(ChannelBufferIndexFinder.CRLF)).toString(UTF_8);
|
ChannelBuffer status = is.readBytes(is.bytesBefore(ChannelBufferIndexFinder.CRLF));
|
||||||
is.skipBytes(2);
|
is.skipBytes(2);
|
||||||
return new StatusReply(status);
|
return new StatusReply(status);
|
||||||
}
|
}
|
||||||
case ErrorReply.MARKER: {
|
case ErrorReply.MARKER: {
|
||||||
String error = is.readBytes(is.bytesBefore(ChannelBufferIndexFinder.CRLF)).toString(UTF_8);
|
ChannelBuffer error = is.readBytes(is.bytesBefore(ChannelBufferIndexFinder.CRLF));
|
||||||
is.skipBytes(2);
|
is.skipBytes(2);
|
||||||
return new ErrorReply(error);
|
return new ErrorReply(error);
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,15 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class StatusReply extends Reply {
|
public class StatusReply extends Reply {
|
||||||
public static final char MARKER = '+';
|
public static final char MARKER = '+';
|
||||||
public final String status;
|
public final ChannelBuffer status;
|
||||||
|
|
||||||
public StatusReply(String status) {
|
public StatusReply(ChannelBuffer status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(ChannelBuffer os) throws IOException {
|
public void write(ChannelBuffer os) throws IOException {
|
||||||
os.writeByte(MARKER);
|
os.writeByte(MARKER);
|
||||||
os.writeBytes(status.getBytes("UTF-8"));
|
os.writeBytes(status);
|
||||||
os.writeBytes(Command.CRLF);
|
os.writeBytes(Command.CRLF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user