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 { addError } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
|
||||
|
||||
|
|
@ -15,10 +15,9 @@ module.exports = {
|
|||
"tags": [ "blockquote", "whitespace" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD028(params, onError) {
|
||||
const micromarkTokens = params.parsers.micromark.tokens;
|
||||
for (const token of filterByTypes(micromarkTokens, [ "blockQuote" ])) {
|
||||
for (const token of filterByTypesCached([ "blockQuote" ])) {
|
||||
const errorLineNumbers = [];
|
||||
const siblings = token.parent?.children || micromarkTokens;
|
||||
const siblings = token.parent?.children || params.parsers.micromark.tokens;
|
||||
for (let i = siblings.indexOf(token) + 1; i < siblings.length; i++) {
|
||||
const sibling = siblings[i];
|
||||
const { startLine, type } = sibling;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue