workers: optimize parser.

This commit is contained in:
Christopher Jeffrey 2016-07-27 02:25:30 -07:00
parent 3f6a93e180
commit 227e9a18b2
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -961,7 +961,7 @@ Parser.prototype.feed = function feed(data) {
if (this.pendingTotal < this.waiting)
break;
chunk = Buffer.concat(this.pending);
chunk = concat(this.pending);
if (chunk.length > this.waiting) {
data = chunk.slice(this.waiting);
@ -1107,6 +1107,12 @@ function fromError(err) {
return [err.message, err.stack + '', err.type];
}
function concat(buffers) {
return buffers.length > 1
? Buffer.concat(buffers)
: buffers[0];
}
/*
* Expose
*/