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 { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { filterByTypes, getTokenParentOfType } = require("../helpers/micromark.cjs");
|
||||
const { getTokenParentOfType } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
const codeFencePrefixRe = /^(.*?)[`~]/;
|
||||
|
||||
|
|
@ -47,8 +48,8 @@ module.exports = {
|
|||
"function": function MD031(params, onError) {
|
||||
const listItems = params.config.list_items;
|
||||
const includeListItems = (listItems === undefined) ? true : !!listItems;
|
||||
const { lines, parsers } = params;
|
||||
for (const codeBlock of filterByTypes(parsers.micromark.tokens, [ "codeFenced" ])) {
|
||||
const { lines } = params;
|
||||
for (const codeBlock of filterByTypesCached([ "codeFenced" ])) {
|
||||
if (includeListItems || !(getTokenParentOfType(codeBlock, [ "listOrdered", "listUnordered" ]))) {
|
||||
if (!isBlankLine(lines[codeBlock.startLine - 2])) {
|
||||
addError(onError, lines, codeBlock.startLine, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue