diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-06-09 03:24:41 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-06-09 12:25:19 +0200 |
commit | aa2bfd69f86acb7952015dc82ef01d8a36dc6efd (patch) | |
tree | 7368a0e77236adf51d55ec0d73a8e4226b5a06b2 /activerecord/lib | |
parent | 066e6c66cecb2abae6b97e1316e77e2a4141fb70 (diff) | |
download | rails-aa2bfd69f86acb7952015dc82ef01d8a36dc6efd.tar.gz rails-aa2bfd69f86acb7952015dc82ef01d8a36dc6efd.tar.bz2 rails-aa2bfd69f86acb7952015dc82ef01d8a36dc6efd.zip |
Merge pull request #6687 from tiegz/3-2-optimizations
ActiveRecord#attributes optimization: minimize objects created
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 39ea885246..c445ec15dd 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -149,7 +149,9 @@ module ActiveRecord # 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 |