Permalink
Browse files

remove unused Buffer-based buffering method

  • Loading branch information...
1 parent a8aefea commit 1a3cb47ee4be23d63b0679644dccde42f11f0b1b @mscdex committed Mar 11, 2013
Showing with 6 additions and 15 deletions.
  1. +6 −15 lib/nntp.js
View
@@ -74,7 +74,7 @@ function NNTP() {
this._queue = undefined;
this._curReq = undefined;
this._stream = undefined;
- this._buffer = undefined;
+ this._buffer = '';
this._bufferEnc = undefined;
this._debug = false;
this.options = {
@@ -151,7 +151,7 @@ NNTP.prototype.connect = function(options) {
this._state = 'connecting';
this.connected = false;
- var isML = false, code, type, retval, buffer = [], bufSize = 0, isErr, sbmh;
+ var isML = false, code, type, retval, isErr, sbmh;
var connTimeout = setTimeout(function() {
self._socket.destroy();
@@ -248,7 +248,6 @@ NNTP.prototype.connect = function(options) {
isML = (RES_CODE_ML.indexOf(code) > -1);
sbmh = (isML ? self._sbmhML : self._sbmhCRLF);
sbmh.reset();
- bufSize = 0;
r = chunk.p;
} else {
r = sbmh.push(chunk, r);
@@ -262,11 +261,7 @@ NNTP.prototype.connect = function(options) {
self._stream.emit('close', isErr);
} else if (isErr)
self._curReq.cb(makeError(ERRORS[code], code));
- else if (self._buffer === undefined) {
- var buf = Buffer.concat(buffer, bufSize);
- buffer = [];
- self._curReq.cb(undefined, code, retval, type, buf);
- } else {
+ else {
self._curReq.cb(undefined, code, retval, type);
self._buffer = '';
}
@@ -281,13 +276,9 @@ NNTP.prototype.connect = function(options) {
function responseHandler(isMatch, chunk, start, end) {
if (isErr || !chunk)
return;
- if (self._stream === undefined) {
- if (self._buffer === undefined) {
- buffer.push(chunk.slice(start, end));
- bufSize += (end - start);
- } else
- self._buffer += chunk.toString(self._bufferEnc || 'utf8', start, end);
- } else
+ if (self._stream === undefined)
+ self._buffer += chunk.toString(self._bufferEnc || 'utf8', start, end);
+ else
self._stream.emit('data', chunk.slice(start, end));
}
this._sbmhML.on('info', responseHandler);

0 comments on commit 1a3cb47

Please sign in to comment.