protobuf
This commit is contained in:
@@ -20,7 +20,7 @@ import static org.redkale.convert.Reader.*;
|
|||||||
*/
|
*/
|
||||||
public class JsonByteBufferReader extends JsonReader {
|
public class JsonByteBufferReader extends JsonReader {
|
||||||
|
|
||||||
private char currentChar;
|
private char cacheChar;
|
||||||
|
|
||||||
private ByteBuffer[] buffers;
|
private ByteBuffer[] buffers;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ public class JsonByteBufferReader extends JsonReader {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean recycle() {
|
protected boolean recycle() {
|
||||||
super.recycle(); // this.position 初始化值为-1
|
super.recycle(); // this.position 初始化值为-1
|
||||||
this.currentChar = 0;
|
this.cacheChar = 0;
|
||||||
this.buffers = null;
|
this.buffers = null;
|
||||||
this.currBufIndex = 0;
|
this.currBufIndex = 0;
|
||||||
this.currentBuffer = null;
|
this.currentBuffer = null;
|
||||||
@@ -70,9 +70,9 @@ public class JsonByteBufferReader extends JsonReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final char nextChar(CharArray sb) {
|
protected final char nextChar(CharArray sb) {
|
||||||
if (currentChar != 0) {
|
if (cacheChar != 0) {
|
||||||
char ch = currentChar;
|
char ch = cacheChar;
|
||||||
this.currentChar = 0;
|
this.cacheChar = 0;
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
if (this.currentBuffer != null) {
|
if (this.currentBuffer != null) {
|
||||||
@@ -155,7 +155,7 @@ public class JsonByteBufferReader extends JsonReader {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected final void backChar(char ch) {
|
protected final void backChar(char ch) {
|
||||||
this.currentChar = ch;
|
this.cacheChar = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ public class ProtobufReader extends Reader {
|
|||||||
|
|
||||||
protected int limit = -1;
|
protected int limit = -1;
|
||||||
|
|
||||||
protected int cacheTag = Integer.MIN_VALUE;
|
protected Integer cacheTag;
|
||||||
|
|
||||||
protected boolean enumtostring;
|
|
||||||
|
|
||||||
private byte[] content;
|
private byte[] content;
|
||||||
|
|
||||||
@@ -38,11 +36,6 @@ public class ProtobufReader extends Reader {
|
|||||||
setBytes(bytes, start, len);
|
setBytes(bytes, start, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtobufReader enumtostring(boolean enumtostring) {
|
|
||||||
this.enumtostring = enumtostring;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepare(byte[] bytes) {
|
public void prepare(byte[] bytes) {
|
||||||
setBytes(bytes);
|
setBytes(bytes);
|
||||||
@@ -80,6 +73,7 @@ public class ProtobufReader extends Reader {
|
|||||||
this.position = -1;
|
this.position = -1;
|
||||||
this.limit = -1;
|
this.limit = -1;
|
||||||
this.content = null;
|
this.content = null;
|
||||||
|
this.cacheTag = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,9 +462,9 @@ public class ProtobufReader extends Reader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected final int readTag() {
|
protected final int readTag() {
|
||||||
if (cacheTag != Integer.MIN_VALUE) {
|
if (cacheTag != null) {
|
||||||
int tag = cacheTag;
|
int tag = cacheTag;
|
||||||
cacheTag = Integer.MIN_VALUE;
|
cacheTag = null;
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
return readRawVarint32();
|
return readRawVarint32();
|
||||||
|
|||||||
Reference in New Issue
Block a user