Incorporating the review comments. While more than 1 charachter might be read from the buffer the output will have only one escaped charachter.

This commit is contained in:
Mohammad Yasir 2017-02-17 11:54:30 +05:30
parent 2d072bae3a
commit 4644837207

View File

@ -1006,13 +1006,12 @@ public class JsonReader implements Closeable {
} else if (c == '\\') {
pos = p;
int len = p - start - 1;
char escapeChar = readEscapeCharacter();
if (builder == null) {
int estimatedLength = (len + pos - p) * 2;
int estimatedLength = (len + 1) * 2;
builder = new StringBuilder(Math.max(estimatedLength, 16));
}
builder.append(buffer, start, len);
builder.append(escapeChar);
builder.append(readEscapeCharacter());
p = pos;
l = limit;
start = p;