mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02: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
|
@ -3,7 +3,8 @@
|
|||
"use strict";
|
||||
|
||||
const { addErrorContext, allPunctuation } = require("../helpers");
|
||||
const { filterByTypes, matchAndGetTokensByType } = require("../helpers/micromark.cjs");
|
||||
const { matchAndGetTokensByType } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
/** @typedef {import("../helpers/micromark.cjs").TokenType} TokenType */
|
||||
/** @type {Map<TokenType, TokenType[]>} */
|
||||
|
@ -24,7 +25,7 @@ module.exports = {
|
|||
punctuation = String((punctuation === undefined) ? allPunctuation : punctuation);
|
||||
const punctuationRe = new RegExp("[" + punctuation + "]$");
|
||||
const paragraphTokens =
|
||||
filterByTypes(params.parsers.micromark.tokens, [ "paragraph" ]).
|
||||
filterByTypesCached([ "paragraph" ]).
|
||||
filter((token) =>
|
||||
(token.parent?.type === "content") && !token.parent?.parent && (token.children.length === 1)
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue