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
10
lib/md003.js
10
lib/md003.js
|
|
@ -3,8 +3,8 @@
|
|||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypes, getHeadingLevel, getHeadingStyle } =
|
||||
require("../helpers/micromark.cjs");
|
||||
const { getHeadingLevel, getHeadingStyle } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
|
|
@ -15,11 +15,7 @@ module.exports = {
|
|||
"parser": "micromark",
|
||||
"function": function MD003(params, onError) {
|
||||
let style = String(params.config.style || "consistent");
|
||||
const headings = filterByTypes(
|
||||
params.parsers.micromark.tokens,
|
||||
[ "atxHeading", "setextHeading" ]
|
||||
);
|
||||
for (const heading of headings) {
|
||||
for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
|
||||
const styleForToken = getHeadingStyle(heading);
|
||||
if (style === "consistent") {
|
||||
style = styleForToken;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue