Open twolfson opened 10 years ago
RegExp shows a ton of promise.
*Match against `3e4 2` characters:**
There is one drawback, JS dislikes RegExp somewhere between 3e4
and 4e4
characters:
'a'.match(new RegExp(new Array(4e4).join('a'))); void 0;
// ... RegExp too big
To work around, that we will probably need to page the content. We already planned on doing so such that we can be aware of repeating variables but we can have super long text blocks.
Thinking about this further, we can probably keep most of the logic and only swap out the variable piece with RegExp. We should add a performance test for loops.
Hi Todd. Thanks for this library. I've used it recently in my repository banking-swift-messages-nodejs. I can see that you had a separate branch for performance enhancements, and that the last update was 2 years ago. Can you give me any tips on how I can go about picking up your repository from where you had left it 2 years ago?
Glad to see someone is putting it to good use =) As mentioned in the README though, this is far from production ready -- there are plenty of edge cases but for your scenario you should be fine.
With respect to performance, I think I wanted a rewrite of the repo due to performance being so poor. There were likely too many bottlenecks to fix and it would be more time efficient to do a rewrite where we constantly check we are not introducing any performance issues.
If you are interested in picking up the repo, I believe I was last exploring what the backbone of the application should be (e.g. do parsing or go to regexp). I should note that mustache
is a frustrating language to reverse against (e.g. #
can mean if
or each
). It might be better to rewrite against another language. In fact, I recall I started that for handlebars here:
https://github.com/twolfson/reverse-template
But I don't think it had any performance work in it =/
The current implementation is wicked slow due. My bet is due to the backoff logic living in JS. If we relocate that to RegExp, we might see significant gains.
For reference, an example of it being slow is:
https://gist.github.com/twolfson/11136618/9ebb41396d5ca2093487d7ea773a231921c798cd