Skip to content

Commit 40154cc

Browse files
author
Ruben Bridgewater
committed
Minor performance optimization
1 parent 108224f commit 40154cc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,14 @@ exports.getKeyIndexes = function (commandName, args, options) {
130130
}
131131
break;
132132
default:
133-
keyStart = command.keyStart - 1;
134-
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1;
135-
if (keyStart >= 0 && keyStop <= args.length && keyStop > keyStart && command.step > 0) {
136-
for (i = keyStart; i < keyStop; i += command.step) {
137-
keys.push(i);
133+
// step has to be at least one in this case, otherwise the command does not contain a key
134+
if (command.step > 0) {
135+
keyStart = command.keyStart - 1;
136+
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1;
137+
if (keyStop <= args.length && keyStop > keyStart) {
138+
for (i = keyStart; i < keyStop; i += command.step) {
139+
keys.push(i);
140+
}
138141
}
139142
}
140143
break;

0 commit comments

Comments
 (0)