Repository navigation
Conversation
Each subtree's HTML used to be copied several times per nesting level, and every text node built a throwaway Arbre::Context. Elements now write into one buffer, and classes that override a rendering or building hook keep going through that override, so output and API stay unchanged. Co-Authored-By: Clanker
Co-Authored-By: Clanker
Builder methods hand their argument array straight to Tag#build's body when build is still Arbre's own, and Element#build takes an anonymous splat it never reads. Overridden or extended builds go the usual way. Co-Authored-By: Clanker
Co-Authored-By: Clanker
Attributes are written in one pass, the opening and closing tags are written inline, and the render-flag lookup reads two instance variables instead of building an array. The override checks stay in place. Co-Authored-By: Clanker
Co-Authored-By: Clanker
Author
|
@tagliala please take a look when you have time |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rendering a large tree now allocates a fraction of the memory, and the output stays byte-identical. Before this change, every nesting level copied its subtree's HTML about five times (
indent,ElementCollection#to_s,html_safe), and each text node built a throwawayArbre::Context. Related to #67.Elements now write into one shared buffer, with the depth passed down instead of walking up the parent chain. A class or a single object that overrides
to_s,content,indent,opening_tag,closing_tag,indent_level,insert_tag,build_tagor a similar hook still renders through that override. Overrides added later throughinclude,prependorextendare detected too. Document writes its doctype into the buffer.Results on a 500-row by 44-cell table:
A real ActiveAdmin 4 index page (500 rows) allocates 2.36M → 0.98M objects, and its HTML is identical to before.
Builder methods also hand their argument array straight to
Tag#build's body whenbuildis still Arbre's own, so a plain tag allocates 4 objects instead of 10.Verification: new specs in
spec/arbre/unit/rendering_spec.rb; 49 edge cases rendered with this branch and with 2.2.1 compare byte for byte, encoding included, under ActiveSupport 8.1 and 7.1; ActiveAdminv4.0.0.beta23's suite passes (1588 examples).