Skip to content

Commit

Permalink
perf: improve performance for rules (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot committed Mar 26, 2022
1 parent ba9ddf6 commit 33eb99e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/iterateJsdoc.js
Expand Up @@ -979,7 +979,7 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
* @param {boolean} additiveContexts
*/
const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveContexts) => {
const trackedJsdocs = [];
const trackedJsdocs = new Set();

let handler;
let settings;
Expand Down Expand Up @@ -1107,7 +1107,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveContexts) => {
}

const commentNode = getJSDocComment(sourceCode, node, settings);
if (trackedJsdocs.includes(commentNode)) {
if (trackedJsdocs.has(commentNode)) {
return;
}

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

trackedJsdocs.push(commentNode);
trackedJsdocs.add(commentNode);
callIterator(context, node, [
commentNode,
], state);
},
'Program:exit' () {
const allComments = sourceCode.getAllComments();
const untrackedJSdoc = allComments.filter((node) => {
return !trackedJsdocs.includes(node);
return !trackedJsdocs.has(node);
});

callIterator(context, null, untrackedJSdoc, state, true);
Expand Down

0 comments on commit 33eb99e

Please sign in to comment.