Skip to content
Browse files

ActiveRecord#attributes optimization: minimize objects created

  • Loading branch information...
1 parent 8475cdd commit 6e4a064256331f21b3b3107e2349f7e7adc6d8e6 @tiegz committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 activerecord/lib/active_record/attribute_methods.rb
View
4 activerecord/lib/active_record/attribute_methods.rb
@@ -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.
def attributes
- Hash[@attributes.map { |name, _| [name, read_attribute(name)] }]
+ attrs = {}
+ attribute_names.each { |name| attrs[name] = read_attribute(name) }
+ attrs
end
# Returns an <tt>#inspect</tt>-like string for the value of the

0 comments on commit 6e4a064

Please sign in to comment.
Something went wrong with that request. Please try again.