Skip to content

Commit

Permalink
Minor performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Bridgewater committed Apr 13, 2016
1 parent 8aba131 commit 9335cc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Features
- Added support for `MIGRATE [...] KEYS key1, key2` (Redis >= v.3.0.6)
- Added build sanity check for unhandled commands with moveable keys
- Rebuild the commands with the newest unstable release
- Improved performance of .getKeyIndexes()

Bugfix

Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ exports.getKeyIndexes = function (commandName, args, options) {
}
break;
default:
keyStart = command.keyStart - 1;
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1;
if (keyStart >= 0 && keyStop <= args.length && keyStop > keyStart && command.step > 0) {
// step has to be at least one in this case, otherwise the command does not contain a key
if (command.step > 0) {
keyStart = command.keyStart - 1;
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1;
for (i = keyStart; i < keyStop; i += command.step) {
keys.push(i);
}
Expand Down

0 comments on commit 9335cc9

Please sign in to comment.