Refactor various code to do shallow/constrained search instead of deep search for better performance, make cache key for filterByTypesCached unique.

This commit is contained in:
David Anson 2024-10-09 22:42:36 -07:00
parent 2fa7730a6b
commit d22c1f19ef
12 changed files with 171 additions and 220 deletions

View file

@ -7,7 +7,6 @@ const { filterByTypes } = require("../helpers/micromark-helpers.cjs");
/** @type {Map<string, object>} */
const map = new Map();
// eslint-disable-next-line no-undef-init
let params = undefined;
/**
@ -46,7 +45,8 @@ function getCached(name, getValue) {
*/
function filterByTypesCached(types, htmlFlow) {
return getCached(
types.join("|"),
// eslint-disable-next-line prefer-rest-params
JSON.stringify(arguments),
() => filterByTypes(params.parsers.micromark.tokens, types, htmlFlow)
);
}