Browse Source

Fix performance when nested token doesn't match

close #53
pull/14/head
Alex Kocharin 10 years ago
parent
commit
1676e10ee8
  1. 6
      lib/links.js
  2. 7
      lib/parser_inline.js
  3. 2
      lib/rules_inline/emphasis.js
  4. 2
      lib/rules_inline/strikethrough.js

6
lib/links.js

@ -7,7 +7,7 @@
// this function assumes that first character ("[") already matches;
// returns the end of the label
function parseLinkLabel(state, start) {
var level, found, marker, ok,
var level, found, marker,
labelEnd = -1,
max = state.posMax,
oldPos = state.pos,
@ -36,9 +36,7 @@ function parseLinkLabel(state, start) {
}
}
ok = state.parser.skipToken(state);
if (!ok) { state.pos++; }
state.parser.skipToken(state);
}
if (found) {

7
lib/parser_inline.js

@ -79,17 +79,18 @@ ParserInline.prototype.skipToken = function (state) {
if ((cached_pos = state.cacheGet(pos)) > 0) {
state.pos = cached_pos;
return true;
return;
}
for (i = 0; i < len; i++) {
if (rules[i](state, true)) {
state.cacheSet(pos, state.pos);
return true;
return;
}
}
return false;
state.pos++;
state.cacheSet(pos, state.pos);
};

2
lib/rules_inline/emphasis.js

@ -112,7 +112,7 @@ module.exports = function emphasis(state, silent) {
}
}
if (!state.parser.skipToken(state)) { state.pos++; }
state.parser.skipToken(state);
}
if (!found) {

2
lib/rules_inline/strikethrough.js

@ -53,7 +53,7 @@ module.exports = function strikethrough(state, silent) {
}
}
if (!state.parser.skipToken(state)) { state.pos++; }
state.parser.skipToken(state);
}
if (!found) {

Loading…
Cancel
Save