From 34ff1efb430b025096df4a8f13b445feeee48c56 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Mon, 28 Jul 2014 08:45:33 +0900 Subject: [PATCH] Simplify DelimitingStream. --- lib/wire/messagestream.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/wire/messagestream.js b/lib/wire/messagestream.js index ccd672a7..66e6cf37 100644 --- a/lib/wire/messagestream.js +++ b/lib/wire/messagestream.js @@ -58,19 +58,14 @@ util.inherits(DelimitingStream, stream.Transform) DelimitingStream.prototype._transform = function(chunk, encoding, done) { var length = chunk.length var lengthBytes = [] - var more = true - while (more) { - if (length > 0x7f) { - lengthBytes.push((1 << 7) + (length & 0x7f)) - length >>= 7 - } - else { - lengthBytes.push(length) - more = false - } + while (length > 0x7f) { + lengthBytes.push((1 << 7) + (length & 0x7f)) + length >>= 7 } + lengthBytes.push(length) + this.push(new Buffer(lengthBytes)) this.push(chunk)