mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 14:30:12 +01:00
Reorder checks in filterByTypes helper predicate for ~2% runtime reduction.
This commit is contained in:
parent
d94b78e6bf
commit
e6e799d145
2 changed files with 2 additions and 4 deletions
|
|
@ -806,8 +806,7 @@ function filterByPredicate(tokens, allowed, transformChildren) {
|
||||||
* @returns {Token[]} Filtered tokens.
|
* @returns {Token[]} Filtered tokens.
|
||||||
*/
|
*/
|
||||||
function filterByTypes(tokens, types, htmlFlow) {
|
function filterByTypes(tokens, types, htmlFlow) {
|
||||||
const predicate = (token) =>
|
const predicate = (token) => types.includes(token.type) && (htmlFlow || !inHtmlFlow(token));
|
||||||
(htmlFlow || !inHtmlFlow(token)) && types.includes(token.type);
|
|
||||||
const flatTokens = tokens[flatTokensSymbol];
|
const flatTokens = tokens[flatTokensSymbol];
|
||||||
if (flatTokens) {
|
if (flatTokens) {
|
||||||
return flatTokens.filter(predicate);
|
return flatTokens.filter(predicate);
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,7 @@ function filterByPredicate(tokens, allowed, transformChildren) {
|
||||||
* @returns {Token[]} Filtered tokens.
|
* @returns {Token[]} Filtered tokens.
|
||||||
*/
|
*/
|
||||||
function filterByTypes(tokens, types, htmlFlow) {
|
function filterByTypes(tokens, types, htmlFlow) {
|
||||||
const predicate = (token) =>
|
const predicate = (token) => types.includes(token.type) && (htmlFlow || !inHtmlFlow(token));
|
||||||
(htmlFlow || !inHtmlFlow(token)) && types.includes(token.type);
|
|
||||||
const flatTokens = tokens[flatTokensSymbol];
|
const flatTokens = tokens[flatTokensSymbol];
|
||||||
if (flatTokens) {
|
if (flatTokens) {
|
||||||
return flatTokens.filter(predicate);
|
return flatTokens.filter(predicate);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue