From 7f275a7be1fbeb9134f77185cab0a6367ad2442c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 17 Jan 2015 12:11:03 -0800 Subject: Slightly adjusted performance optimization in new block starts. --- js/lib/blocks.js | 11 +++++++---- 1 file 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); -- cgit v1.2.3