Skip to content

Commit 153567a

Browse files
author
Ruben Bridgewater
committed
Minor performance optimization
1 parent 0f15dc2 commit 153567a

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
@@ -131,11 +131,14 @@ exports.getKeyIndexes = function (commandName, args, options) {
131131
}
132132
break;
133133
default:
134-
keyStart = command.keyStart - 1;
135-
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1;
136-
if (keyStart >= 0 && keyStop <= args.length && keyStop > keyStart && command.step > 0) {
137-
for (i = keyStart; i < keyStop; i += command.step) {
138-
keys.push(i);
134+
// step has to be at least one in this case, otherwise the command does not contain a key
135+
if (command.step > 0) {
136+
keyStart = command.keyStart - 1;
137+
keyStop = command.keyStop > 0 ? command.keyStop : args.length + command.keyStop + 1;
138+
if (keyStop <= args.length && keyStop > keyStart) {
139+
for (i = keyStart; i < keyStop; i += command.step) {
140+
keys.push(i);
141+
}
139142
}
140143
}
141144
break;

0 commit comments

Comments
 (0)