From 9c218c305e175183abd577c07daec5daf230801c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 11 Sep 2014 09:24:24 -0700 Subject: Clarified code logic for last_emphasis_closer. --- js/stmd.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/stmd.js b/js/stmd.js index 1b82fd5..250814e 100755 --- a/js/stmd.js +++ b/js/stmd.js @@ -294,8 +294,12 @@ var parseEmphasis = function() { var last_emphasis_closer = null; var delims_to_match = numdelims; - while (this.last_emphasis_closer === null || - this.last_emphasis_closer >= this.pos) { + + // 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) { @@ -325,11 +329,13 @@ var parseEmphasis = function() { } else { break; } + } } // didn't find closing delimiter this.pos = startpos + numdelims; if (last_emphasis_closer === null) { + // we know there are no closers after startpos, so: this.last_emphasis_closer = startpos; } else { this.last_emphasis_closer = last_emphasis_closer; -- cgit v1.2.3