From 8b2c98f6c7c0b7371265905a43fc7d3ad966643a Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Tue, 18 Nov 2014 11:26:16 -0800 Subject: Remove call to `key?` in `LazyAttributeHash#[]` Performance improvement, as well as improved code clarity --- activerecord/lib/active_record/attribute_set/builder.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'activerecord/lib') 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) -- cgit v1.2.3