From 190a8563abb0ce87de9e131606e5d51bc2ac84c5 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Fri, 17 Oct 2014 01:19:13 +0400 Subject: [PATCH] Perf: optimized html block names lookup --- lib/common/html_blocks.js | 8 ++++++-- lib/rules_block/htmlblock.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/common/html_blocks.js b/lib/common/html_blocks.js index 97fb1e6..91f5f3b 100644 --- a/lib/common/html_blocks.js +++ b/lib/common/html_blocks.js @@ -3,8 +3,9 @@ 'use strict'; +var html_blocks = {}; -module.exports = [ +[ 'article', 'aside', 'button', @@ -55,4 +56,7 @@ module.exports = [ 'thead', 'ul', 'video' -]; +].forEach(function (name) { html_blocks[name] = true; }); + + +module.exports = html_blocks; diff --git a/lib/rules_block/htmlblock.js b/lib/rules_block/htmlblock.js index 9d4ef96..f067d71 100644 --- a/lib/rules_block/htmlblock.js +++ b/lib/rules_block/htmlblock.js @@ -48,7 +48,7 @@ module.exports = function htmlblock(state, startLine, endLine, silent) { if (!match) { return false; } } // Make sure tag name is valid - if (block_names.indexOf(match[1].toLowerCase()) < 0) { return false; } + if (block_names[match[1].toLowerCase()] !== true) { return false; } if (silent) { return true; } } else {