Skip to content
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

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Nov 19, 2024

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.

@st0012 st0012 self-assigned this Nov 19, 2024
end

def eval_instance_variables
::Kernel.instance_method(:instance_variables).bind(eval("self")).call
KERNEL_INSTANCE_VARIABLES.bind(eval("self")).call
Copy link
Member

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.

end

def eval_global_variables
::Kernel.instance_method(:global_variables).bind(eval("self")).call
KERNEL_GLOBAL_VARIABLES.bind(eval("self")).call
Copy link
Member

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.
@st0012 st0012 force-pushed the store-methods-in-constants branch from bda99c0 to 5bf7e6a Compare November 20, 2024 17:35
@st0012 st0012 requested a review from tompng November 20, 2024 17:35
Copy link
Member

@tompng tompng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@tompng tompng merged commit f1e25ec into master Nov 20, 2024
55 of 59 checks passed
@tompng tompng deleted the store-methods-in-constants branch November 20, 2024 18:59
matzbot pushed a commit to ruby/ruby that referenced this pull request Nov 20, 2024
(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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants