From 5a2b54fd2f83825f3f4db59b5dc89989173d04a8 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 8 Sep 2015 02:06:28 +0200 Subject: [PATCH] Remove dead code from js parser --- lib/parser/javascript.js | 41 +++++++++------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/lib/parser/javascript.js b/lib/parser/javascript.js index bdb7578841..a6ad8892fa 100644 --- a/lib/parser/javascript.js +++ b/lib/parser/javascript.js @@ -55,19 +55,13 @@ ReplyParser.prototype._parseResult = function (type) { } if (type === 45) { - var result = this._buffer.toString(this._encoding, start, end); - return new Error(result); - } - - if (this.options.return_buffers) { + return new Error(this._buffer.toString(this._encoding, start, end)); + } else if (this.options.return_buffers) { return this._buffer.slice(start, end); - } else { - if (end - start < 65536) { // completely arbitrary - return small_toString(this._buffer, start, end); - } else { - return this._buffer.toString(this._encoding, start, end); - } + } else if (end - start < 65536) { // completely arbitrary + return small_toString(this._buffer, start, end); } + return this._buffer.toString(this._encoding, start, end); } else if (type === 58) { // : // up to the delimiter end = this._packetEndOffset() - 1; @@ -92,7 +86,7 @@ ReplyParser.prototype._parseResult = function (type) { // packets with a size of -1 are considered null if (packetHeader.size === -1) { - return undefined; + return null; } end = this._offset + packetHeader.size; @@ -108,10 +102,9 @@ ReplyParser.prototype._parseResult = function (type) { if (this.options.return_buffers) { return this._buffer.slice(start, end); - } else { - return this._buffer.toString(this._encoding, start, end); } - } else if (type === 42) { // * + return this._buffer.toString(this._encoding, start, end); + } else { // * offset = this._offset; packetHeader = new Packet(type, this.parseHeader()); @@ -136,9 +129,6 @@ ReplyParser.prototype._parseResult = function (type) { throw new IncompleteReadBuffer("Wait for more data."); } res = this._parseResult(ntype); - if (res === undefined) { - res = null; - } reply.push(res); } @@ -176,18 +166,8 @@ ReplyParser.prototype.execute = function (buffer) { } else if (type === 36) { // $ ret = this._parseResult(type); - if (ret === null) { - break; - } - - // check the state for what is the result of - // a -1, set it back up for a null reply - if (ret === undefined) { - ret = null; - } - this.send_reply(ret); - } else if (type === 42) { // * + } else if (type === 42) { // 42 * // set a rewind point. if a failure occurs, // wait for the next execute()/append() and try again offset = this._offset - 1; @@ -199,9 +179,6 @@ ReplyParser.prototype.execute = function (buffer) { } catch (err) { // catch the error (not enough data), rewind, and wait // for the next packet to appear - if (! (err instanceof IncompleteReadBuffer)) { - throw err; - } this._offset = offset; break; }