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 { addErrorDetailIf } = require("../helpers");
|
||||
const { addRangeToSet, filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { addRangeToSet } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
|
@ -14,9 +15,9 @@ module.exports = {
|
|||
"parser": "micromark",
|
||||
"function": function MD012(params, onError) {
|
||||
const maximum = Number(params.config.maximum || 1);
|
||||
const { lines, parsers } = params;
|
||||
const { lines } = params;
|
||||
const codeBlockLineNumbers = new Set();
|
||||
for (const codeBlock of filterByTypes(parsers.micromark.tokens, [ "codeFenced", "codeIndented" ])) {
|
||||
for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
|
||||
addRangeToSet(codeBlockLineNumbers, codeBlock.startLine, codeBlock.endLine);
|
||||
}
|
||||
let count = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue