Skip to content
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

Optimize bytecode amount #206

Merged
merged 1 commit into from
Dec 7, 2023

Commits on Dec 6, 2023

  1. Optimize to generate less bytecode

    It was possible for the macros to generate so much bytecode that they
    would exceed Java's 64KB limit for method code size. In such situations
    the Clojure compiler would fail with the message "Method code too
    large!" See weavejester#205
    
    This commit does the following optimizations:
    
    1. Concatenate string literals at compile time, so that we can replace
       multiple StringBuilder.append() calls with just one. This reduces the
       generated code from O(n) to O(1). This also improves performance by
       10-20%, since copying one long string is faster than many short
       strings.
    
    2. When a runtime check is needed to determine whether a value is the
       element's attribute map or its first child element, avoid duplicating
       the code for the element's content. This reduces the generated code
       from O(n^2) to O(n).
    
    While improving the test coverage, some edge cases of generating bad
    HTML were detected. This commit doesn't change the existing behavior,
    but only documents it in the new tests. Fixing that behavior will be
    done in future commits.
    luontola committed Dec 6, 2023
    3 Configuration menu
    Copy the full SHA
    00ddf99 View commit details
    Browse the repository at this point in the history