Skip to content
This repository
Browse code

Merge pull request #6687 from tiegz/3-2-optimizations

ActiveRecord#attributes optimization: minimize objects created
  • Loading branch information...
commit aa2bfd69f86acb7952015dc82ef01d8a36dc6efd 1 parent 066e6c6
José Valim authored June 09, 2012 josevalim committed June 09, 2012
4  activerecord/lib/active_record/attribute_methods.rb
@@ -149,7 +149,9 @@ def attribute_names
149 149
 
150 150
     # Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
151 151
     def attributes
152  
-      Hash[@attributes.map { |name, _| [name, read_attribute(name)] }]
  152
+      attrs = {}
  153
+      attribute_names.each { |name| attrs[name] = read_attribute(name) }
  154
+      attrs
153 155
     end
154 156
 
155 157
     # Returns an <tt>#inspect</tt>-like string for the value of the

0 notes on commit aa2bfd6

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