From 402331ed2dedd2c2328a6b353341bd9eca7b6aa6 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 1 Mar 2015 16:05:50 -0800 Subject: drop string allocations per model url_for call in views ```ruby article = Article.new.tap(&:save!) view.url_for article result = ObjectSpace::AllocationTracer.trace do 3000.times { view.url_for article } end p ObjectSpace::AllocationTracer.allocated_count_table[:T_STRING] / 3000 ``` --- actionpack/lib/action_dispatch/http/url.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 001b14ec97..7da6301ac4 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -67,7 +67,7 @@ module ActionDispatch end def path_for(options) - path = options[:script_name].to_s.chomp("/") + path = options[:script_name].to_s.chomp("/".freeze) path << options[:path] if options.key?(:path) add_trailing_slash(path) if options[:trailing_slash] -- cgit v1.2.3