aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_set
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-11-18 11:26:16 -0800
committerSean Griffin <sean@thoughtbot.com>2014-11-18 12:32:09 -0800
commit8b2c98f6c7c0b7371265905a43fc7d3ad966643a (patch)
treed00379c2b405e1fa37aa5ac947db6b1926bdc2f9 /activerecord/lib/active_record/attribute_set
parent6f5d633271b01737cd32d2935d4c3279c95613a3 (diff)
downloadrails-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/lib/active_record/attribute_set')
-rw-r--r--activerecord/lib/active_record/attribute_set/builder.rb6
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)