Skip to content

Commit bf0acfe

Browse files
use standard loops and array.push for performance
realised that performance matter a lot for eslint, and functional map, recursive calls and converting forth and back between set and creating new arrays would not be very performant, so changed implementation to old style loops and working with a single SET
1 parent 1c38930 commit bf0acfe

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/rules/noUndefinedTypes.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,14 @@ export default iterateJsdoc(({
227227
* @returns {Set<string>}
228228
*/
229229
const getValidRuntimeIdentifiers = (scope) => {
230-
return scope
231-
? new Set([
232-
...new Set(scope.variables.map(({ name }) => name)),
233-
...getValidRuntimeIdentifiers(scope.upper),
234-
])
235-
: new Set();
230+
const result = new Set()
231+
while (scope) {
232+
for (const {name} of scope.variables) {
233+
result.add(name)
234+
}
235+
scope = scope.upper
236+
}
237+
return result
236238
};
237239

238240
const allDefinedTypes = new Set(globalScope.variables.map(({

0 commit comments

Comments
 (0)