-
Notifications
You must be signed in to change notification settings - Fork 847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
my pull requests and further branches/work #288
Comments
timings current master vs optimize_combine_append_calls Master:
optimize-combine-append-calls
the runtime (cached) performance of "large tmpl" is in huge parts because the template has many <%%, and they no longer split the text into many __append. Compared to
refactor_preview_next_token also has NO split for <%%. But it does NOT join other __append calls |
plugin-snippetssee #274 optimizationsAdded a cache for the fs.fileExists call (obeying opts.cache) Also added a key to module exports to allow hooking fileExists (same as for loading a file) Made a small optimization to regex, small speed gain. plugin-ejs-localssee https://github.com/RandomEtc/ejs-locals This is used by some frameworks. And if not available can prevent upgrading. I had to expose some more functions in ejs.
If this is not desired, I can copy them to the plugin. plugin-opts-filterFor people still stuck on express 3 or anything using the old (IIRC 3 arg) renderFile. It can happen that locals and options get mixed up. This plugin allows to filter them out. |
This is to serve as an overview for the changes/pullrequests that I made.
refactor-generate-source
basic refactor: move functionality into scanLine. Making it easier for future plugins to change behaviour by overwriting scanLine.
This is continued in refactor-generate-source-full-tokens.
It also contains some changes that speed up compilation. Some of them could be implemented independent of the refactor.
refactor-generate-source-full-tokens
Scanline is now replaced by
literals are handled before passing to those function.
As a result text is no longer split at literals, and both functions are always called with the full tag between <%...%> ( or %>...<% for scanTextLine)
For templates containing literal <%% this also results in less __append in the compiled output, and therefore a speed up of the generated function.
Having less calls to scanTagLine has a positive effect on compilation speed.
Due to the current handling of unmatched close tags, and literals, the regex got more complicated.
The new scanTagLine requiring openTag and closeTag,also means that it will be harder to implement stand-alone tags or nested tags.
E.g. a literal section
<%[ now all is literal %> and <% are just text ]%>
will not work. Because the tags are expected in pairs.
If that is a concern then lets look at alternatives. From my various attempts on changing the main loop, I expect that passing the tokens individually will come with a slow down of compilation).
A plugin could overwrite the entire
generateSource
function, which is the loop that splits the text into tokens.On the other hand, being guaranteed the full content of each tag makes other tasks easier.
<% include 'foo<%%bar' %>
(filename contains <% )This also depends on #284
refacter-preview-next-token
changes scanTextLine: function (line)
to scanTextLine: function (line, prevCloseTag, nextOpenTag)
Passing the tags in, allows the function to handle the space slurping.
This also fixes the hardcoded regex for <%_ which did non use opts.delimiter.
optimize_combine_append_calls
Speed up (in none compileDebug) for the generated functions.
In the generated code, consecutive
__append
calls are merged to__append(a,b,c)
Less calls => faster.
This helps for templates with many <%- / <%= tags. Since those and the html in between them all use __append.
Templates with a lot of <% if (...) %> tags, will not benefit as much.
The text was updated successfully, but these errors were encountered: