aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-09-26 11:01:20 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-09-26 11:01:20 -0700
commit151cb9e51b25bfd644e1920c078ca894fc9e7e9d (patch)
treef48a95ce0fed038e18db35eeb010adbbee9634ef /js
parent50d87813fc96ea8d5c2610f3fad134f8d4f8e286 (diff)
Used last_emphasis_closer to avoid unneeded scans for closer.
This doesn't seem to help much.
Diffstat (limited to 'js')
-rwxr-xr-xjs/stmd.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/js/stmd.js b/js/stmd.js
index 5a09875..287a0c9 100755
--- a/js/stmd.js
+++ b/js/stmd.js
@@ -312,6 +312,7 @@
var state = 0;
var can_close = false;
var can_open = false;
+ var last_emphasis_closer = null;
if (numdelims === 3) {
state = 1;
@@ -322,11 +323,17 @@
}
while (true) {
+ if (this.last_emphasis_closer[c] < this.pos) {
+ break;
+ }
res = this.scanDelims(c);
if (res) {
numdelims = res.numdelims;
can_close = res.can_close;
+ if (can_close) {
+ last_emphasis_closer = this.pos;
+ }
can_open = res.can_open;
switch (state) {
case 1: // ***a
@@ -458,6 +465,9 @@
// we didn't match emphasis: fallback
this.pos = fallbackpos;
+ if (last_emphasis_closer) {
+ this.last_emphasis_closer[c] = last_emphasis_closer;
+ }
return [fallback];
};
@@ -783,7 +793,7 @@
this.subject = s;
this.pos = 0;
this.refmap = refmap || {};
- this.last_emphasis_closer = null;
+ this.last_emphasis_closer = { '*': s.length, '_': s.length };
var inlines = [];
var next_inline;
while ((next_inline = this.parseInline())) {