From 13c4cc3b5aea02716b7459c0da641438077f5236 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 18 Feb 2016 07:50:53 -0800 Subject: remove object `hash` cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I don't think caching this method makes any difference on Ruby 2.0: ``` require 'benchmark/ips' class Foo alias :object_hash :hash attr_reader :hash def initialize @hash = object_hash end end class Bar end hash = {} foo = Foo.new bar = Bar.new Benchmark.ips do |x| x.report("foo") { hash[foo] } x.report("bar") { hash[bar] } x.report("foo.hash") { foo.hash } x.report("bar.hash") { bar.hash } end __END__ [aaron@TC ruby (trunk)]$ ruby test.rb Warming up -------------------------------------- foo 118.361k i/100ms bar 118.637k i/100ms Calculating ------------------------------------- foo 7.944M (± 3.1%) i/s - 39.769M bar 7.931M (± 3.4%) i/s - 39.625M [aaron@TC ruby (trunk)]$ ruby test.rb Warming up -------------------------------------- foo 122.180k i/100ms bar 120.492k i/100ms foo.hash 123.397k i/100ms bar.hash 119.312k i/100ms Calculating ------------------------------------- foo 8.002M (± 4.2%) i/s - 39.953M bar 8.037M (± 4.5%) i/s - 40.124M foo.hash 8.819M (± 3.9%) i/s - 44.053M bar.hash 7.856M (± 4.1%) i/s - 39.254M ``` --- actionview/lib/action_view/lookup_context.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index 126f289f55..2a1f4378f5 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -55,9 +55,7 @@ module ActionView class DetailsKey #:nodoc: alias :eql? :equal? - alias :object_hash :hash - attr_reader :hash @details_keys = Concurrent::Map.new def self.get(details) @@ -71,10 +69,6 @@ module ActionView def self.clear @details_keys.clear end - - def initialize - @hash = object_hash - end end # Add caching behavior on top of Details. -- cgit v1.2.3