Skip to content

Reduce allocations in #with_collection #2333

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mvz
Copy link

@mvz mvz commented Jun 6, 2025

What are you trying to accomplish?

Speed up rendering when there are lots of calls to #with_collection for the same componen, for example when rendering a collection of items, where each item contains a collection of sub-items.

What approach did you choose and why?

I focused on reducing redundant allocation of string objects. This is because rack-mini-profiler's flamegraph showed me lots of repeats of the same string interpolation.

Anything you want to highlight for special attention from reviewers?

The code setting the expected number of allocations will have to be updated to include values for all the relevant Ruby and Rails versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant