diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-01 22:57:34 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-01 23:41:51 +0000 |
commit | 6bff6439b1960891669485dc978af68dab15af27 (patch) | |
tree | 19b2cbd98d90af78a970486d35fbbd239ce6045a /activerecord/lib | |
parent | f6b5046305d43c5f64bcb6fed0e44f7bca99a603 (diff) | |
download | rails-6bff6439b1960891669485dc978af68dab15af27.tar.gz rails-6bff6439b1960891669485dc978af68dab15af27.tar.bz2 rails-6bff6439b1960891669485dc978af68dab15af27.zip |
Fewer string allocations in attribute method
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 54949ce0e2..769aa36e79 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -76,17 +76,17 @@ module ActiveRecord end def internal_attribute_access_code(attr_name, cast_code) - access_code = "(v=@attributes['#{attr_name}']) && #{cast_code}" + access_code = "(v=@attributes[attr_name]) && #{cast_code}" unless attr_name == primary_key - access_code.insert(0, "missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); ") + access_code.insert(0, "missing_attribute(attr_name, caller) unless @attributes.has_key?(attr_name); ") end if cache_attribute?(attr_name) - access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})" + access_code = "@attributes_cache[attr_name] ||= (#{access_code})" end - access_code + "attr_name = '#{attr_name}'; #{access_code}" end def external_attribute_access_code(attr_name, cast_code) |