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
12
lib/md054.js
12
lib/md054.js
|
|
@ -3,9 +3,8 @@
|
|||
"use strict";
|
||||
|
||||
const { addErrorContext, nextLinesRe } = require("../helpers");
|
||||
const { filterByTypes, filterByPredicate, getTokenTextByType } =
|
||||
require("../helpers/micromark.cjs");
|
||||
const { referenceLinkImageData } = require("./cache");
|
||||
const { filterByPredicate, getTokenTextByType } = require("../helpers/micromark.cjs");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
|
||||
const backslashEscapeRe = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;
|
||||
const removeBackslashEscapes = (text) => text.replace(backslashEscapeRe, "$1");
|
||||
|
|
@ -40,11 +39,8 @@ module.exports = {
|
|||
// Everything allowed, nothing to check
|
||||
return;
|
||||
}
|
||||
const { definitions } = referenceLinkImageData();
|
||||
const links = filterByTypes(
|
||||
params.parsers.micromark.tokens,
|
||||
[ "autolink", "image", "link" ]
|
||||
);
|
||||
const { definitions } = getReferenceLinkImageData();
|
||||
const links = filterByTypesCached([ "autolink", "image", "link" ]);
|
||||
for (const link of links) {
|
||||
let label = null;
|
||||
let destination = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue