summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-09-11 10:53:40 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-09-11 11:17:42 -0700
commit25f65e91293f1bfd74f81a78e2dac2cdbaa55e98 (patch)
tree437a33fae827a04a2e2b2fa020b89e2973f00917 /js
parent026fd723dc8bc327b86096c489df5b8f8e9035ba (diff)
Fixed performance regression from eccc23dc8d.
Diffstat (limited to 'js')
-rwxr-xr-xjs/stmd.js60
1 files changed, 29 insertions, 31 deletions
diff --git a/js/stmd.js b/js/stmd.js
index 4b80581..187d058 100755
--- a/js/stmd.js
+++ b/js/stmd.js
@@ -297,38 +297,36 @@
// We need not look for closers if we have already recorded that
// there are no closers past this point.
- if (this.last_emphasis_closer === null ||
- this.last_emphasis_closer >= this.pos) {
- while (true) {
- res = this.scanDelims(c);
- numclosedelims = res.numdelims;
- if (res.can_close) {
- if (last_emphasis_closer === null ||
- last_emphasis_closer < this.pos) {
- last_emphasis_closer = this.pos;
- }
- if (numclosedelims === 3 && delims_to_match === 3) {
- this.pos += 3;
- this.last_emphasis_closer = null;
- return {t: 'Strong', c: [{t: 'Emph', c: inlines}]};
- } else if (numclosedelims >= 2 && delims_to_match >= 2) {
- delims_to_match -= 2;
- this.pos += 2;
- inlines = [{t: 'Strong', c: inlines}];
- } else if (numclosedelims >= 1 && delims_to_match >= 1) {
- delims_to_match -= 1;
- this.pos += 1;
- inlines = [{t: 'Emph', c: inlines}];
- }
- if (delims_to_match === 0) {
- this.last_emphasis_closer = null;
- return inlines[0];
- }
- } else if ((next_inline = this.parseInline())) {
- inlines.push(next_inline);
- } else {
- break;
+ while (this.last_emphasis_closer === null ||
+ this.last_emphasis_closer >= this.pos) {
+ res = this.scanDelims(c);
+ numclosedelims = res.numdelims;
+ if (res.can_close) {
+ if (last_emphasis_closer === null ||
+ last_emphasis_closer < this.pos) {
+ last_emphasis_closer = this.pos;
}
+ if (numclosedelims === 3 && delims_to_match === 3) {
+ this.pos += 3;
+ this.last_emphasis_closer = null;
+ return {t: 'Strong', c: [{t: 'Emph', c: inlines}]};
+ } else if (numclosedelims >= 2 && delims_to_match >= 2) {
+ delims_to_match -= 2;
+ this.pos += 2;
+ inlines = [{t: 'Strong', c: inlines}];
+ } else if (numclosedelims >= 1 && delims_to_match >= 1) {
+ delims_to_match -= 1;
+ this.pos += 1;
+ inlines = [{t: 'Emph', c: inlines}];
+ }
+ if (delims_to_match === 0) {
+ this.last_emphasis_closer = null;
+ return inlines[0];
+ }
+ } else if ((next_inline = this.parseInline())) {
+ inlines.push(next_inline);
+ } else {
+ break;
}
}