From aa2bfd69f86acb7952015dc82ef01d8a36dc6efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 9 Jun 2012 03:24:41 -0700 Subject: Merge pull request #6687 from tiegz/3-2-optimizations ActiveRecord#attributes optimization: minimize objects created --- activerecord/lib/active_record/attribute_methods.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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 #inspect-like string for the value of the -- cgit v1.2.3