aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-17 12:11:03 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-17 12:11:03 -0800
commit7f275a7be1fbeb9134f77185cab0a6367ad2442c (patch)
treefbb259b89088dc8f82c9bb62db7c26ebe896de23
parentf37efa9f0d4085ac21b528135184517e6c4e4cb3 (diff)
Slightly adjusted performance optimization in new block starts.
-rw-r--r--js/lib/blocks.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/js/lib/blocks.js b/js/lib/blocks.js
index d4f6790..6f44b48 100644
--- a/js/lib/blocks.js
+++ b/js/lib/blocks.js
@@ -19,7 +19,7 @@ var reHtmlBlockOpen = new RegExp('^' + HTMLBLOCKOPEN, 'i');
var reHrule = /^(?:(?:\* *){3,}|(?:_ *){3,}|(?:- *){3,}) *$/;
-var reMaybeSpecial = /^[ #`~*+_=<>0-9-]/;
+var reMaybeSpecial = /^[#`~*+_=<>0-9-]/;
var reNonSpace = /[^ \t\n]/;
@@ -363,9 +363,7 @@ var incorporateLine = function(ln) {
// Unless last matched container is a code block, try new container starts,
// adding children to the last matched container:
var t = container.type;
- while (t !== 'CodeBlock' && t !== 'HtmlBlock' &&
- // this is a little performance optimization:
- matchAt(reMaybeSpecial, ln, offset) !== -1) {
+ while (t !== 'CodeBlock' && t !== 'HtmlBlock') {
match = matchAt(reNonSpace, ln, offset);
if (match === -1) {
@@ -389,6 +387,11 @@ var incorporateLine = function(ln) {
break;
}
+ // this is a little performance optimization:
+ if (matchAt(reMaybeSpecial, ln, first_nonspace) === -1) {
+ break;
+ }
+
offset = first_nonspace;
var cc = ln.charCodeAt(offset);