Convert helpers.filterTokens from Array.forEach to for..of for ~6% time reduction measured via profile-fixture.mjs on Apple Silicon M1.

This commit is contained in:
David Anson 2022-06-07 22:59:48 -07:00
parent 604ff5df39
commit 15efcb4282
2 changed files with 4 additions and 4 deletions

View file

@ -278,11 +278,11 @@ module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
* @returns {void}
*/
function filterTokens(params, type, handler) {
params.tokens.forEach(function forToken(token) {
for (const token of params.tokens) {
if (token.type === type) {
handler(token);
}
});
}
}
module.exports.filterTokens = filterTokens;
/**

View file

@ -273,11 +273,11 @@ module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
* @returns {void}
*/
function filterTokens(params, type, handler) {
params.tokens.forEach(function forToken(token) {
for (const token of params.tokens) {
if (token.type === type) {
handler(token);
}
});
}
}
module.exports.filterTokens = filterTokens;