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,7 @@
|
|||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
|
|
@ -17,11 +17,7 @@ module.exports = {
|
|||
const olSingle = Number(params.config.ol_single || 1);
|
||||
const ulMulti = Number(params.config.ul_multi || 1);
|
||||
const olMulti = Number(params.config.ol_multi || 1);
|
||||
const lists = filterByTypes(
|
||||
params.parsers.micromark.tokens,
|
||||
[ "listOrdered", "listUnordered" ]
|
||||
);
|
||||
for (const list of lists) {
|
||||
for (const list of filterByTypesCached([ "listOrdered", "listUnordered" ])) {
|
||||
const ordered = (list.type === "listOrdered");
|
||||
const listItemPrefixes =
|
||||
list.children.filter((token) => (token.type === "listItemPrefix"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue