Skip to content

Commit b862347

Browse files
committed
Break out of some loops in sort-comp
I noticed a couple of cases where we continue looping even though we don't need to anymore. In these special keyword cases, we can break out of these loops as soon as we find a match to get a little bit of a speed boost.
1 parent 1bc58f4 commit b862347

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/rules/sort-comp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ module.exports = Components.detect(function(context, components) {
9898
for (i = 0, j = methodsOrder.length; i < j; i++) {
9999
if (methodsOrder[i] === 'static-methods') {
100100
indexes.push(i);
101+
break;
101102
}
102103
}
103104
}
@@ -123,6 +124,7 @@ module.exports = Components.detect(function(context, components) {
123124
for (i = 0, j = methodsOrder.length; i < j; i++) {
124125
if (methodsOrder[i] === 'everything-else') {
125126
indexes.push(i);
127+
break;
126128
}
127129
}
128130
}

0 commit comments

Comments
 (0)