Use early return to make code a bit more readable

This commit is contained in:
Vladimir Grichina 2019-03-26 15:17:45 -07:00
parent 9b4431d73c
commit 1aca8f6b4c

View File

@ -202,12 +202,11 @@ export class JSONDecoder<JSONHandlerT extends JSONHandler> {
assert(byte >= 0x20, "Unexpected control character");
if (byte == '"'.charCodeAt(0)) {
let s = String.fromUTF8(this.state.buffer.buffer.data + savedIndex, this.state.readIndex - savedIndex - 1);
if (stringParts != null) {
stringParts.push(s);
return stringParts.join("");
} else {
if (stringParts == null) {
return s;
}
stringParts.push(s);
return stringParts.join("");
} else if (byte == "\\".charCodeAt(0)) {
if (stringParts == null) {
stringParts = new Array<string>();