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

ActiveRecord#attributes optimization: minimize objects created #6687

Merged
merged 1 commit into from Jun 9, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/attribute_methods.rb
Expand Up @@ -181,7 +181,9 @@ def attribute_names


# Returns a hash of all the attributes with their names as keys and the values of the attributes as values. # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
def attributes def attributes
Hash[@attributes.map { |name, _| [name, read_attribute(name)] }] attrs = {}
attribute_names.each { |name| attrs[name] = read_attribute(name) }
attrs
end end


# Returns an <tt>#inspect</tt>-like string for the value of the # Returns an <tt>#inspect</tt>-like string for the value of the
Expand Down