Forward component blocks directly during recursive graph traversal - #35
Open
OskarEichler wants to merge 1 commit into
Open
Forward component blocks directly during recursive graph traversal#35OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
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.
Summary
Forward the component callback directly through the recursive traversal instead of wrapping it in a new block at every level. This removes wrapper allocations and repeated callback relays while preserving component ordering and cycle semantics.
Measurement and verification
On macOS/Ruby 4.0.6 through rbenv, seven samples of 50 sorts of a 300-node chain:
These are local microbenchmark results, not a claim about every graph or Rails startup. The improvement removes the nested callback relay as each component is emitted.
git diff --checkpass. The release-based package retains 11 files, Ruby >=2.3.0 and no runtime dependencies/extensions.No tests were added or changed under the requesting project's explicit policy. The graph checker and benchmark are external scratch scripts. Other Ruby versions and OSs were not run locally.
Breaking changes and limitations
None intended. Callback order, yielded values, self-loop treatment and multi-node cycle errors are preserved. In particular, this does not change the behavior discussed in #4. The traversal itself remains recursive; this is not a stack-safe rewrite for arbitrarily deep graphs. Reflection now exposes a named block parameter on the two internal traversal entry points.