From 1aca8f6b4ccebe9df3339f94c0f6c661434b460d Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Tue, 26 Mar 2019 15:17:45 -0700 Subject: [PATCH] Use early return to make code a bit more readable --- assembly/decoder.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/assembly/decoder.ts b/assembly/decoder.ts index b4923ef..c3bf52e 100644 --- a/assembly/decoder.ts +++ b/assembly/decoder.ts @@ -202,12 +202,11 @@ export class JSONDecoder { 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();