You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Tiny speedup by removing command.toLowerCase()
This is not necessary as the command itself is only used from inside the code and as they are (now) all lower case it is safe to remove the toLowerCase
This commit is contained in:
15
index.js
15
index.js
@@ -624,14 +624,14 @@ RedisClient.prototype.return_reply = function (reply) {
|
||||
|
||||
if (command_obj && !command_obj.sub_command) {
|
||||
if (typeof command_obj.callback === "function") {
|
||||
if (this.options.detect_buffers && command_obj.buffer_args === false && 'exec' !== command_obj.command.toLowerCase()) {
|
||||
if (this.options.detect_buffers && command_obj.buffer_args === false && 'exec' !== command_obj.command) {
|
||||
// If detect_buffers option was specified, then the reply from the parser will be Buffers.
|
||||
// If this command did not use Buffer arguments, then convert the reply to Strings here.
|
||||
reply = reply_to_strings(reply);
|
||||
}
|
||||
|
||||
// TODO - confusing and error-prone that hgetall is special cased in two places
|
||||
if (reply && 'hgetall' === command_obj.command.toLowerCase()) {
|
||||
if (reply && 'hgetall' === command_obj.command) {
|
||||
reply = reply_to_object(reply);
|
||||
}
|
||||
|
||||
@@ -730,8 +730,7 @@ RedisClient.prototype.send_command = function (command, args, callback) {
|
||||
// client.sadd(arg1, [arg2, arg3, arg4], cb);
|
||||
// converts to:
|
||||
// client.sadd(arg1, arg2, arg3, arg4, cb);
|
||||
lcaseCommand = command.toLowerCase();
|
||||
if ((lcaseCommand === 'sadd' || lcaseCommand === 'srem') && args.length > 0 && Array.isArray(args[args.length - 1])) {
|
||||
if ((command === 'sadd' || command === 'srem') && args.length > 0 && Array.isArray(args[args.length - 1])) {
|
||||
args = args.slice(0, -1).concat(args[args.length - 1]);
|
||||
}
|
||||
|
||||
@@ -885,7 +884,7 @@ RedisClient.prototype.end = function () {
|
||||
|
||||
function Multi(client, args) {
|
||||
this._client = client;
|
||||
this.queue = [["MULTI"]];
|
||||
this.queue = [["multi"]];
|
||||
if (Array.isArray(args)) {
|
||||
this.queue = this.queue.concat(args);
|
||||
}
|
||||
@@ -1061,7 +1060,7 @@ Multi.prototype.exec = function (callback) {
|
||||
if (args.length === 1 && Array.isArray(args[0])) {
|
||||
args = args[0];
|
||||
}
|
||||
if (command.toLowerCase() === 'hmset' && typeof args[1] === 'object') {
|
||||
if (command === 'hmset' && typeof args[1] === 'object') {
|
||||
obj = args.pop();
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
args.push(key);
|
||||
@@ -1081,7 +1080,7 @@ Multi.prototype.exec = function (callback) {
|
||||
}, this);
|
||||
|
||||
// TODO - make this callback part of Multi.prototype instead of creating it each time
|
||||
return this._client.send_command("EXEC", [], function (err, replies) {
|
||||
return this._client.send_command("exec", [], function (err, replies) {
|
||||
if (err) {
|
||||
if (callback) {
|
||||
errors.push(new Error(err));
|
||||
@@ -1106,7 +1105,7 @@ Multi.prototype.exec = function (callback) {
|
||||
}
|
||||
|
||||
// TODO - confusing and error-prone that hgetall is special cased in two places
|
||||
if (reply && args[0].toLowerCase() === "hgetall") {
|
||||
if (reply && args[0] === "hgetall") {
|
||||
replies[i - 1] = reply = reply_to_object(reply);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user