mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +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
10
lib/md039.js
10
lib/md039.js
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { referenceLinkImageData } = require("./cache");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
|
||||
/**
|
||||
* Adds an error for a label space issue.
|
||||
|
|
@ -56,11 +56,9 @@ module.exports = {
|
|||
"tags": [ "whitespace", "links" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD039(params, onError) {
|
||||
const { definitions } = referenceLinkImageData();
|
||||
const labels = filterByTypes(
|
||||
params.parsers.micromark.tokens,
|
||||
[ "label" ]
|
||||
).filter((label) => label.parent?.type === "link");
|
||||
const { definitions } = getReferenceLinkImageData();
|
||||
const labels = filterByTypesCached([ "label" ]).
|
||||
filter((label) => label.parent?.type === "link");
|
||||
for (const label of labels) {
|
||||
const labelTexts = filterByTypes(
|
||||
label.children,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue