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

Optimize Database#setup_attachment_class method #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

radarek
Copy link

@radarek radarek commented Feb 23, 2015

Fix #16 "Speed regression for #attachment accessor (getter) between 2.2.2 and 2.3.1 version".

# Pick the top-most definition like
# Paperclip::AttachmentRegistry#definitions_for
names_for_ancestor = ancestor.attachment_definitions.keys rescue []
if names_for_ancestor.member?(name)
if ancestor.attachment_definitions.member?(name)
@attachment_class = ancestor
Copy link
Author

Choose a reason for hiding this comment

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

Can't we break after first definition found? Why comment says that we are looking for top-most definition? How about class A defining attachment and class B < A overriding attachment definition? In this case I think we should get definitions from class B but this code will find definition from A.

@radarek
Copy link
Author

radarek commented Feb 28, 2015

@jarl-dk Could you review and eventually merge this pull?

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.

Speed regression for #attachment accessor (getter) between 2.2.2 and 2.3.1 version
1 participant