diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-11-18 11:26:16 -0800 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-11-18 12:32:09 -0800 |
commit | 8b2c98f6c7c0b7371265905a43fc7d3ad966643a (patch) | |
tree | d00379c2b405e1fa37aa5ac947db6b1926bdc2f9 /activerecord | |
parent | 6f5d633271b01737cd32d2935d4c3279c95613a3 (diff) | |
download | rails-8b2c98f6c7c0b7371265905a43fc7d3ad966643a.tar.gz rails-8b2c98f6c7c0b7371265905a43fc7d3ad966643a.tar.bz2 rails-8b2c98f6c7c0b7371265905a43fc7d3ad966643a.zip |
Remove call to `key?` in `LazyAttributeHash#[]`
Performance improvement, as well as improved code clarity
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_set/builder.rb | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/attribute_set/builder.rb b/activerecord/lib/active_record/attribute_set/builder.rb index 60154a0647..b433205af3 100644 --- a/activerecord/lib/active_record/attribute_set/builder.rb +++ b/activerecord/lib/active_record/attribute_set/builder.rb @@ -35,11 +35,7 @@ module ActiveRecord end def [](key) - if delegate_hash.key?(key) - delegate_hash[key] - else - assign_default_value(key) - end + delegate_hash[key] || assign_default_value(key) end def []=(key, value) |