mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Cache all top-level calls to filterByTypes (~7% runtime reduction).
This commit is contained in:
parent
85e704f32a
commit
dfcb4529f3
47 changed files with 427 additions and 481 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
const { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
|
|
@ -20,10 +20,7 @@ module.exports = {
|
|||
);
|
||||
const trailingPunctuationRe =
|
||||
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
|
||||
const headings = filterByTypes(
|
||||
params.parsers.micromark.tokens,
|
||||
[ "atxHeadingText", "setextHeadingText" ]
|
||||
);
|
||||
const headings = filterByTypesCached([ "atxHeadingText", "setextHeadingText" ]);
|
||||
for (const heading of headings) {
|
||||
const { endColumn, endLine, text } = heading;
|
||||
const match = trailingPunctuationRe.exec(text);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue