From 1993e2ccbd7c5651278ea30bdc9d8034f5197945 Mon Sep 17 00:00:00 2001 From: schneems Date: Sat, 25 Jul 2015 16:58:22 -0500 Subject: Avoid hash duplication by skipping mutation If we don't mutate the `recall` hash, then there's no reason to duplicate it. While this change doesn't get rid of that many objects, each hash object it gets rid of was massive. Saves 888 string objects per request, 206,013 bytes (thats 0.2 mb which is kinda a lot). --- actionpack/lib/action_dispatch/routing/route_set.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 848b20b054..a006a146ed 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -599,7 +599,7 @@ module ActionDispatch def initialize(named_route, options, recall, set) @named_route = named_route @options = options - @recall = recall.dup + @recall = recall @set = set normalize_recall! @@ -621,7 +621,7 @@ module ActionDispatch def use_recall_for(key) if @recall[key] && (!@options.key?(key) || @options[key] == @recall[key]) if !named_route_exists? || segment_keys.include?(key) - @options[key] = @recall.delete(key) + @options[key] = @recall[key] end end end -- cgit v1.2.3