-
Notifications
You must be signed in to change notification settings - Fork 479
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
Treat formats and buffers as interchangeable when they are mixed together #511
Conversation
⭐ |
Can this work without changing the grammar. It's not back compat (what I'm probably missing how combining buffers solve the issue. What about the idea for a pre compilation step. |
It's not as pretty, but let me see if I can maintain perf. We lose a lot of speed at the compilation step by manually combining nodes. I get the desire to maintain grammar, though. I'm not sure the value that we get by separating out the newline from any following space (except for backcompat) |
OK, we don't lose that much speed. About 8%. Grammar is now backwards-compatible. dustc now has a --whitespace flag you can set to true to preserve whitespace on the command-line. Default behavior is still |
…ther. During the compiler's optimization pass, "format" globs (basically whitespace) are stripped out. The remaining strings, "buffers", are concatenated into a single entity. If whitespace compression is disabled, formats and buffers are all written, but the two types are not concatenated together. Because most code is broken up by newlines, this results in highly-inefficient chunking of writes that-- in the case of large templates-- causes Dust to exceed the call stack limit. This patch adds dust.config.whitespace (set by default for now to false for backwards compatibility; by default there is zero change with or without the patch) to toggle the whitespace stripping behavior. When the flag is set to true (respect whitespace), the new format/buffer concat logic is invoked. Also adds --whitespace=true|false (default false) flag to dustc. Closes linkedin#498
665275c
to
a3bd24b
Compare
lgtm, one more look from @jimmyhchan |
}; | ||
|
||
// Directive aliases to minify code | ||
dust._aliases = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need these public?
edit: nvm yes you do.. silly compiler.
the minified stuff looks good thanks for that. |
Treat formats and buffers as interchangeable when they are mixed together in order to prevent stack overflows with large templates and add a whitespace flag to dust.config
During the compiler's optimization pass, "format" globs (basically whitespace) are stripped out. The remaining strings, "buffers", are concatenated into a single entity.
If whitespace compression is disabled, formats and buffers are all written, but the two types are not concatenated together. Because most code is broken up by newlines, this results in highly-inefficient chunking of writes that-- in the case of large templates-- causes Dust to exceed the call stack limit.
This patch adds dust.config.whitespace (set by default for now to false for backwards compatibility; by default there is zero change with or without the patch) to toggle the whitespace stripping behavior. When the flag is set to true (allow whitespace), the new format/buffer concat logic is invoked.
Closes #498