- Commit
- 7f275a7be1fbeb9134f77185cab0a6367ad2442c
- Parent
- f37efa9f0d4085ac21b528135184517e6c4e4cb3
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Slightly adjusted performance optimization in new block starts.
My personal build of CMark ✏️
Slightly adjusted performance optimization in new block starts.
1 file changed, 7 insertions, 4 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | js/lib/blocks.js | 11 | 7 | 4 |
diff --git 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);