This commit is contained in:
redkale
2024-09-30 10:11:40 +08:00
parent dad7d38202
commit 40000ae026
2 changed files with 10 additions and 16 deletions

View File

@@ -20,7 +20,7 @@ import static org.redkale.convert.Reader.*;
*/
public class JsonByteBufferReader extends JsonReader {
private char currentChar;
private char cacheChar;
private ByteBuffer[] buffers;
@@ -38,7 +38,7 @@ public class JsonByteBufferReader extends JsonReader {
@Override
protected boolean recycle() {
super.recycle(); // this.position 初始化值为-1
this.currentChar = 0;
this.cacheChar = 0;
this.buffers = null;
this.currBufIndex = 0;
this.currentBuffer = null;
@@ -70,9 +70,9 @@ public class JsonByteBufferReader extends JsonReader {
}
protected final char nextChar(CharArray sb) {
if (currentChar != 0) {
char ch = currentChar;
this.currentChar = 0;
if (cacheChar != 0) {
char ch = cacheChar;
this.cacheChar = 0;
return ch;
}
if (this.currentBuffer != null) {
@@ -155,7 +155,7 @@ public class JsonByteBufferReader extends JsonReader {
*/
@Override
protected final void backChar(char ch) {
this.currentChar = ch;
this.cacheChar = ch;
}
/**

View File

@@ -20,9 +20,7 @@ public class ProtobufReader extends Reader {
protected int limit = -1;
protected int cacheTag = Integer.MIN_VALUE;
protected boolean enumtostring;
protected Integer cacheTag;
private byte[] content;
@@ -38,11 +36,6 @@ public class ProtobufReader extends Reader {
setBytes(bytes, start, len);
}
public ProtobufReader enumtostring(boolean enumtostring) {
this.enumtostring = enumtostring;
return this;
}
@Override
public void prepare(byte[] bytes) {
setBytes(bytes);
@@ -80,6 +73,7 @@ public class ProtobufReader extends Reader {
this.position = -1;
this.limit = -1;
this.content = null;
this.cacheTag = null;
return true;
}
@@ -468,9 +462,9 @@ public class ProtobufReader extends Reader {
}
protected final int readTag() {
if (cacheTag != Integer.MIN_VALUE) {
if (cacheTag != null) {
int tag = cacheTag;
cacheTag = Integer.MIN_VALUE;
cacheTag = null;
return tag;
}
return readRawVarint32();