aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-11-19 11:24:49 -0800
committerSean Griffin <sean@thoughtbot.com>2014-11-19 11:24:49 -0800
commitb03f9ef86a44b190948be0737bf9ab68e30fc112 (patch)
tree435f0fb71c6aebbde9087dc372a4491c2f9d590d /activerecord/lib/active_record/type
parent74c35b46e362a128fe06f909744da8bb1aeed0e0 (diff)
downloadrails-b03f9ef86a44b190948be0737bf9ab68e30fc112.tar.gz
rails-b03f9ef86a44b190948be0737bf9ab68e30fc112.tar.bz2
rails-b03f9ef86a44b190948be0737bf9ab68e30fc112.zip
Revert "PERF: optimise type lookup to avoid invoking procs"
This reverts commit da99a2a2982d35f670ad9647463e09bfe9032b70.
Diffstat (limited to 'activerecord/lib/active_record/type')
-rw-r--r--activerecord/lib/active_record/type/hash_lookup_type_map.rb20
1 files changed, 1 insertions, 19 deletions
diff --git a/activerecord/lib/active_record/type/hash_lookup_type_map.rb b/activerecord/lib/active_record/type/hash_lookup_type_map.rb
index 2a146d38a9..bf92680268 100644
--- a/activerecord/lib/active_record/type/hash_lookup_type_map.rb
+++ b/activerecord/lib/active_record/type/hash_lookup_type_map.rb
@@ -1,12 +1,6 @@
module ActiveRecord
module Type
class HashLookupTypeMap < TypeMap # :nodoc:
-
- def initialize
- @cache = {}
- super
- end
-
delegate :key?, to: :@mapping
def lookup(type, *args)
@@ -14,24 +8,12 @@ module ActiveRecord
end
def fetch(type, *args, &block)
- cache = (@cache[type] ||= {})
- resolved = cache[args]
-
- unless resolved
- resolved = cache[args] = @mapping.fetch(type, block).call(type, *args)
- end
-
- resolved
+ @mapping.fetch(type, block).call(type, *args)
end
def alias_type(type, alias_type)
register_type(type) { |_, *args| lookup(alias_type, *args) }
end
-
- def register_type(key, value=nil, &block)
- @cache = {}
- super(key, value, &block)
- end
end
end
end