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
|
|
@ -3,7 +3,8 @@
|
|||
"use strict";
|
||||
|
||||
const { addError, withinAnyRange } = require("../helpers");
|
||||
const { addRangeToSet, getExclusionsForToken, filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { addRangeToSet, getExclusionsForToken } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
const reversedLinkRe =
|
||||
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
|
@ -16,13 +17,12 @@ module.exports = {
|
|||
"tags": [ "links" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD011(params, onError) {
|
||||
const { tokens } = params.parsers.micromark;
|
||||
const codeBlockLineNumbers = new Set();
|
||||
for (const codeBlock of filterByTypes(tokens, [ "codeFenced", "codeIndented" ])) {
|
||||
for (const codeBlock of filterByTypesCached([ "codeFenced", "codeIndented" ])) {
|
||||
addRangeToSet(codeBlockLineNumbers, codeBlock.startLine, codeBlock.endLine);
|
||||
}
|
||||
const exclusions = [];
|
||||
for (const codeText of filterByTypes(tokens, [ "codeText" ])) {
|
||||
for (const codeText of filterByTypesCached([ "codeText" ])) {
|
||||
exclusions.push(...getExclusionsForToken(params.lines, codeText));
|
||||
}
|
||||
for (const [ lineIndex, line ] of params.lines.entries()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue