diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-09-26 11:11:01 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-09-26 11:11:01 -0700 |
commit | 2d43050a1c62a3e6a7ef5e0d286828adc72e4bb4 (patch) | |
tree | 04de362f34e3fa637eda535f3e1a075e34bd4653 /js/stmd.js | |
parent | 78ad57d6919c20831c8f6d3455a72d431afd1715 (diff) |
Only memoize during inline parsing.
This cuts the performance hit.
With memoization, we get roughly constant behavior in the fuzztest.
Without it, not.
Diffstat (limited to 'js/stmd.js')
-rwxr-xr-x | js/stmd.js | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -455,7 +455,7 @@ } } - if ((next_inline = this.parseInline())) { + if ((next_inline = this.parseInline(true))) { Array.prototype.push.apply(current, next_inline); } else { break; @@ -743,10 +743,10 @@ // Parse the next inline element in subject, advancing subject position // and returning the inline parsed. - var parseInline = function() { + var parseInline = function(memoize) { var startpos = this.pos; - var memoized = this.memo[startpos]; + var memoized = memoize && this.memo[startpos]; if (memoized) { this.pos = memoized.endpos; return memoized.inline; @@ -793,7 +793,7 @@ res = [{t: 'Str', c: c}]; } - if (res) { + if (res && memoize) { this.memo[startpos] = { inline: res, endpos: this.pos }; } |