1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Improve performance further

This commit is contained in:
Ruben Bridgewater
2015-10-05 10:57:57 +02:00
parent 2232a8948e
commit e47ba4a583
5 changed files with 54 additions and 50 deletions

View File

@@ -2,9 +2,8 @@
var util = require('util');
function ReplyParser(return_buffers) {
function ReplyParser() {
this.name = exports.name;
this.return_buffers = return_buffers;
this._buffer = new Buffer(0);
this._offset = 0;
@@ -37,10 +36,8 @@ ReplyParser.prototype._parseResult = function (type) {
if (type === 45) {
return new Error(this._buffer.toString(this._encoding, start, end));
} else if (this.return_buffers) {
return this._buffer.slice(start, end);
}
return this._buffer.toString(this._encoding, start, end);
return this._buffer.slice(start, end);
} else if (type === 58) { // :
// up to the delimiter
end = this._packetEndOffset() - 1;
@@ -77,15 +74,12 @@ ReplyParser.prototype._parseResult = function (type) {
// set the offset to after the delimiter
this._offset = end + 2;
if (this.return_buffers) {
return this._buffer.slice(start, end);
}
return this._buffer.toString(this._encoding, start, end);
return this._buffer.slice(start, end);
} else if (type === 42) { // *
offset = this._offset;
packetHeader = this.parseHeader();
if (packetHeader < 0) {
if (packetHeader === -1) {
return null;
}