mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +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 { addErrorContextForLine, isBlankLine } = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
|
|
@ -13,12 +13,9 @@ module.exports = {
|
|||
"tags": [ "table" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD058(params, onError) {
|
||||
const { lines, parsers } = params;
|
||||
const { lines } = params;
|
||||
// For every table...
|
||||
const tables = filterByTypes(
|
||||
parsers.micromark.tokens,
|
||||
[ "table" ]
|
||||
);
|
||||
const tables = filterByTypesCached([ "table" ]);
|
||||
for (const table of tables) {
|
||||
// Look for a blank line above the table
|
||||
const firstIndex = table.startLine - 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue