mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30: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
|
|
@ -3,8 +3,8 @@
|
|||
"use strict";
|
||||
|
||||
const { addError, addErrorContext } = require("../helpers");
|
||||
const { filterByTypes, getTokenTextByType, tokenIfType } =
|
||||
require("../helpers/micromark.cjs");
|
||||
const { getTokenTextByType, tokenIfType } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
|
|
@ -17,10 +17,7 @@ module.exports = {
|
|||
let allowed = params.config.allowed_languages;
|
||||
allowed = Array.isArray(allowed) ? allowed : [];
|
||||
const languageOnly = !!params.config.language_only;
|
||||
const fencedCodes = filterByTypes(
|
||||
params.parsers.micromark.tokens,
|
||||
[ "codeFenced" ]
|
||||
);
|
||||
const fencedCodes = filterByTypesCached([ "codeFenced" ]);
|
||||
for (const fencedCode of fencedCodes) {
|
||||
const openingFence = tokenIfType(fencedCode.children[0], "codeFencedFence");
|
||||
if (openingFence) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue