-
Notifications
You must be signed in to change notification settings - Fork 121
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
Store method objects in constants #1033
Conversation
lib/irb/completion.rb
Outdated
end | ||
|
||
def eval_instance_variables | ||
::Kernel.instance_method(:instance_variables).bind(eval("self")).call | ||
KERNEL_INSTANCE_VARIABLES.bind(eval("self")).call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use bind_call(receiver)
for the above three.
lib/irb/completion.rb
Outdated
end | ||
|
||
def eval_global_variables | ||
::Kernel.instance_method(:global_variables).bind(eval("self")).call | ||
KERNEL_GLOBAL_VARIABLES.bind(eval("self")).call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::Kernel.global_variables
is better because this does not need to look into self
It probably won't speed up things significantly, but these are hot paths and we can save a few method calls per completion/input call.
bda99c0
to
5bf7e6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
(ruby/irb#1033) It probably won't speed up things significantly, but these are hot paths and we can save a few method calls per completion/input call. ruby/irb@f1e25ec7ae
It probably won't speed up things significantly, but these are hot paths and we can save a few method calls per completion/input call.