Read instance variables directly instead of evaluating Ruby source - #95
Open
OskarEichler wants to merge 1 commit into
Open
Read instance variables directly instead of evaluating Ruby source#95OskarEichler 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
Read listed instance variables through the core getter, using PP.mcall, instead of compiling Ruby source with instance_eval. Objects overriding instance_eval currently print the override's result instead of their stored variable values.
Reproduction and verification
An Object with @x=123 and an instance_eval override returning :wrong currently renders @x=:wrong. Also checked overridden instance_variable_get, mixed symbol/string names, missing/nil/false variables and Unicode names across 500 objects. Local five-sample benchmark, 200 renders of 30 variables: about 16–21ms before, 6.4ms after; Ruby allocations roughly unchanged. No application-throughput claim.
RBENV_VERSION=4.0.6 rbenv exec rake test: 36 tests / 56 assertions, zero failures before and after.Breaking-change notes
Listed names continue to mean instance-variable names. Core storage reads now ignore overrides of instance_eval/instance_variable_get; custom presentation belongs in pretty_print. Normal output is unchanged.