Browse Source

Perf: escaping

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
9fbeb5a6ec
  1. 9
      lib/rules_inline/escape.js

9
lib/rules_inline/escape.js

@ -1,8 +1,9 @@
// Proceess escaped chars and hardbreaks
var ESCAPED = '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
.split('')
.map(function(ch) { return ch.charCodeAt(0); });
var ESCAPED = {};
'\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
.split('').forEach(function(ch) { ESCAPED[ch.charCodeAt(0)] = true; });
module.exports = function escape(state) {
var ch, pos = state.pos, max = state.posMax;
@ -14,7 +15,7 @@ module.exports = function escape(state) {
if (pos < max) {
ch = state.src.charCodeAt(pos);
if (ESCAPED.indexOf(ch) >= 0) {
if (typeof ESCAPED[ch] !== 'undefined') {
// escape html chars if needed
if (ch === 0x26/* & */) {
state.pending += '&amp;';

Loading…
Cancel
Save