-
Notifications
You must be signed in to change notification settings - Fork 175
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
Exponential increase in generated code when there are multiple nested hiccup2.core/html calls #210
Comments
Macros are evaluated from the outside in, so we could certainly look through the syntax tree and do something to reduce the nesting. There may also be a better solution to the problem, but keeping the API backward compatible ties our hands somewhat. |
If Alternatively, create a new internal function similar to |
This is similar to #205 but less common. Consider the following code:
In the generated code, foo will appear 8 times, bar 64 times, and gazonk 512 times.
If you try to evaluate this code normally (i.e. without macroexpand-all), it will throw "IndexOutOfBoundsException: Method code too large!"
Each level of nesting multiplies the code by 8, because every
h/html
checkshiccup.util/*html-mode*
andhiccup.util/*escape-strings?*
again and generates the 8 code paths.Is there a way for a Clojure macro to recognize that it's nested within itself? Then those 8 code paths could be generated at only the outermost
h/html
, and the inner macros could use the same html and escape mode as the outermost macro.Hiccup version 2.0.0-RC3
Workaround
Extract the inner
html
macro call to a function, so that you won't have many nestedhtml
macros.The text was updated successfully, but these errors were encountered: