Permalink
Browse files

zlib: use Buffer.concat()

  • Loading branch information...
1 parent 8ccb3cb commit a111390c566c61074e4452481abf190fd955fa30 @isaacs isaacs committed Jun 15, 2012
Showing with 1 addition and 19 deletions.
  1. +1 −19 lib/zlib.js
View
20 lib/zlib.js
@@ -150,25 +150,7 @@ function zlibBuffer(engine, buffer, callback) {
}
function onEnd() {
- var buffer;
- switch (buffers.length) {
- case 0:
- buffer = new Buffer(0);
- break;
- case 1:
- buffer = buffers[0];
- break;
- default:
- buffer = new Buffer(nread);
- var n = 0;
- buffers.forEach(function(b) {
- var l = b.length;
- b.copy(buffer, n, 0, l);
- n += l;
- });
- break;
- }
- callback(null, buffer);
+ callback(null, Buffer.concat(buffers, nread));
}
engine.on('error', onError);

0 comments on commit a111390

Please sign in to comment.