Skip to content

Commit 33eb99e

Browse files
authored
perf: improve performance for rules (#856)
1 parent ba9ddf6 commit 33eb99e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/iterateJsdoc.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
979979
* @param {boolean} additiveContexts
980980
*/
981981
const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveContexts) => {
982-
const trackedJsdocs = [];
982+
const trackedJsdocs = new Set();
983983

984984
let handler;
985985
let settings;
@@ -1107,7 +1107,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveContexts) => {
11071107
}
11081108

11091109
const commentNode = getJSDocComment(sourceCode, node, settings);
1110-
if (trackedJsdocs.includes(commentNode)) {
1110+
if (trackedJsdocs.has(commentNode)) {
11111111
return;
11121112
}
11131113

@@ -1122,15 +1122,15 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveContexts) => {
11221122
return;
11231123
}
11241124

1125-
trackedJsdocs.push(commentNode);
1125+
trackedJsdocs.add(commentNode);
11261126
callIterator(context, node, [
11271127
commentNode,
11281128
], state);
11291129
},
11301130
'Program:exit' () {
11311131
const allComments = sourceCode.getAllComments();
11321132
const untrackedJSdoc = allComments.filter((node) => {
1133-
return !trackedJsdocs.includes(node);
1133+
return !trackedJsdocs.has(node);
11341134
});
11351135

11361136
callIterator(context, null, untrackedJSdoc, state, true);

0 commit comments

Comments
 (0)