Cache all top-level calls to filterByTypes (~7% runtime reduction).

This commit is contained in:
David Anson 2024-08-24 22:05:16 -07:00
parent 85e704f32a
commit dfcb4529f3
47 changed files with 427 additions and 481 deletions

View file

@ -604,14 +604,13 @@ function lintContent(
const parsersNone = Object.freeze({});
const paramsBase = {
name,
"parsers": parsersMarkdownIt,
"lines": Object.freeze(lines),
"frontMatterLines": Object.freeze(frontMatterLines)
};
const referenceLinkImageData =
helpers.getReferenceLinkImageData(micromarkTokens);
cache.set({
referenceLinkImageData
cache.initialize({
...paramsBase,
"parsers": parsersMicromark,
"config": null
});
// Function to run for each rule
let results = [];
@ -826,7 +825,7 @@ function lintContent(
} catch (error) {
callbackError(error);
} finally {
cache.clear();
cache.initialize();
}
}