You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
zero-length bulk data + int optimization
This commit is contained in:
9
index.js
9
index.js
@@ -68,7 +68,7 @@ RedisReplyParser.prototype.execute = function (incoming_buf) {
|
|||||||
break;
|
break;
|
||||||
case "integer line":
|
case "integer line":
|
||||||
if (incoming_buf[pos] === 13) {
|
if (incoming_buf[pos] === 13) {
|
||||||
this.send_reply(parseInt(small_toString(this.return_buffer), 10));
|
this.send_reply(+small_toString(this.return_buffer));
|
||||||
this.state = "final lf";
|
this.state = "final lf";
|
||||||
} else {
|
} else {
|
||||||
this.return_buffer[this.return_buffer.end] = incoming_buf[pos];
|
this.return_buffer[this.return_buffer.end] = incoming_buf[pos];
|
||||||
@@ -114,7 +114,7 @@ RedisReplyParser.prototype.execute = function (incoming_buf) {
|
|||||||
break;
|
break;
|
||||||
case "multi bulk count lf":
|
case "multi bulk count lf":
|
||||||
if (incoming_buf[pos] === 10) { // \n
|
if (incoming_buf[pos] === 10) { // \n
|
||||||
this.multi_bulk_length = parseInt(small_toString(this.tmp_buffer), 10);
|
this.multi_bulk_length = +small_toString(this.tmp_buffer);
|
||||||
this.multi_bulk_replies = [];
|
this.multi_bulk_replies = [];
|
||||||
this.state = "type";
|
this.state = "type";
|
||||||
if (0 == this.multi_bulk_length) {
|
if (0 == this.multi_bulk_length) {
|
||||||
@@ -138,10 +138,13 @@ RedisReplyParser.prototype.execute = function (incoming_buf) {
|
|||||||
break;
|
break;
|
||||||
case "bulk lf":
|
case "bulk lf":
|
||||||
if (incoming_buf[pos] === 10) { // \n
|
if (incoming_buf[pos] === 10) { // \n
|
||||||
this.bulk_length = parseInt(small_toString(this.tmp_buffer), 10);
|
this.bulk_length = +small_toString(this.tmp_buffer);
|
||||||
if (this.bulk_length === -1) {
|
if (this.bulk_length === -1) {
|
||||||
this.send_reply(null);
|
this.send_reply(null);
|
||||||
this.state = "type";
|
this.state = "type";
|
||||||
|
} else if (this.bulk_length === 0) {
|
||||||
|
this.send_reply(new Buffer(""));
|
||||||
|
this.state = "final cr";
|
||||||
} else {
|
} else {
|
||||||
this.state = "bulk data";
|
this.state = "bulk data";
|
||||||
if (this.bulk_length > this.return_buffer.length) {
|
if (this.bulk_length > this.return_buffer.length) {
|
||||||
|
Reference in New Issue
Block a user