Browse Source

Perf: md unescaping opt

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
6c3ba9eb99
  1. 7
      lib/rules_inline/escape.js

7
lib/rules_inline/escape.js

@ -1,10 +1,13 @@
// Proceess escaped chars and hardbreaks // Proceess escaped chars and hardbreaks
var ESCAPED = {}; var ESCAPED = [];
for (var i = 0; i < 256; i++) { ESCAPED.push(false); }
'\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-' '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
.split('').forEach(function(ch) { ESCAPED[ch.charCodeAt(0)] = true; }); .split('').forEach(function(ch) { ESCAPED[ch.charCodeAt(0)] = true; });
module.exports = function escape(state, silent) { module.exports = function escape(state, silent) {
var ch, pos = state.pos, max = state.posMax; var ch, pos = state.pos, max = state.posMax;
@ -15,7 +18,7 @@ module.exports = function escape(state, silent) {
if (pos < max) { if (pos < max) {
ch = state.src.charCodeAt(pos); ch = state.src.charCodeAt(pos);
if (typeof ESCAPED[ch] !== 'undefined') { if (ch < 256 && ESCAPED[ch] !== 0) {
if (!silent) { state.pending += state.src[pos]; } if (!silent) { state.pending += state.src[pos]; }
state.pos += 2; state.pos += 2;
return true; return true;

Loading…
Cancel
Save