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

Change order in if clause for should_use_cache? #566

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

kirs
Copy link
Contributor

@kirs kirs commented Mar 18, 2024

When records are preloaded from database using Post.includes(:author).find(id), fetch_author will fallback to returning the object that was preloaded from the database.

However, it still goes through association_klass.should_use_cache? which started appearing on our profiles.

association_klass.should_use_cache? is the more expensive check so it's gotta be in the end of if clause.

@kirs kirs requested a review from danmayer March 18, 2024 18:47
Copy link

@danmayer danmayer left a comment

Choose a reason for hiding this comment

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

good call, thanks for fixing this

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.

None yet

3 participants