Repository navigation
Conversation
TextNode.from_string called Element#initialize, which built an Arbre::Context and a child collection for every text node. Few text nodes ever read either. Co-Authored-By: Clanker
senid231
force-pushed
the
perf/lazy-text-node
branch
from
December 3, 2026 15:24
4fc22bf to
537c5a8
Compare
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.
Text nodes no longer build an
Arbre::Contextand a child collection when they are created. They build them the first time something reads them.TextNode.from_string, which wraps every string added to an element, passed no context, soElement#initializecreated a fullContextfor each one. This is the change suggested in the review of #756, split out so its gain is measured on its own.On a 500-row by 44-cell table, building the tree allocates 636k objects instead of 772k (42.4 MB instead of 54.0 MB). Rendering is unchanged, so this is about 5% of the bytes allocated overall. Wall time shows no measurable difference.
Freezing a text node builds both first, so a frozen node can still read them.
Verification: new examples in
spec/arbre/unit/html/text_node_spec.rb. The 23 examples from #761 pass with this change.