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

Make module tracking lazy #1978

Merged
merged 1 commit into from Apr 26, 2024
Merged

Make module tracking lazy #1978

merged 1 commit into from Apr 26, 2024

Conversation

vinistock
Copy link
Member

Motivation

This is a small optimization to how we're tracking included and prepended modules. There's no need to eagerly create the arrays to store them, since there might be many modules that don't include or prepend anything.

Implementation

Made the modules initialization lazy, so that the arrays are only created if we actually found an include or prepend.

@vinistock vinistock added server This pull request should be included in the server gem's release notes other Changes that aren't bugfixes, enhancements or breaking changes labels Apr 25, 2024
@vinistock vinistock self-assigned this Apr 25, 2024
@vinistock vinistock requested a review from a team as a code owner April 25, 2024 20:59
@vinistock vinistock requested review from andyw8 and st0012 April 25, 2024 20:59
Copy link
Contributor

@aryan-soni aryan-soni 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!

@vinistock vinistock merged commit 9b31275 into main Apr 26, 2024
42 of 44 checks passed
@vinistock vinistock deleted the vs/make_module_tracking_lazy branch April 26, 2024 13:41
attr_accessor :included_modules
sig { returns(String) }
def short_name
T.must(@name.split("::").last)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be memoized?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is actually dead #1980. Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other Changes that aren't bugfixes, enhancements or breaking changes server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants