mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Reduce the number of times #clean_path_info
is called
It's unnecessary to call `#clean_path_info`. It doesn't need to be called on the path with each extension. This reduces allocations to `Rack::Utils` in integration tests. Before `#clean_path_info` from `Rack::Utils` (line 622) was number 2 in top 5 allocations: ``` [["rack/lib/rack/utils.rb", 499, :T_STRING], [51034, 4539, 71559, 0, 12, 1791120]] [["rack/lib/rack/utils.rb", 662, :T_STRING], [33012, 0, 27930, 0, 1, 1226009]] [["rails/activesupport/lib/active_support/notifications/fanout.rb", 55, :T_DATA], [29998, 0, 25380, 0, 1, 3230600]] [["rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [29996, 0, 25378, 0, 2, 1113840]] [["rails/activesupport/lib/active_support/notifications/instrumenter.rb", 52, :T_HASH], [29994, 147, 27014, 0, 11, 4897784]] ``` After `#clean_path_info` from `Rack::Utils` (line 622) does not appear in the top 5 highest allocations: ``` [["rack/lib/rack/utils.rb", 499, :T_STRING], [47617, 2414, 68969, 0, 12, 1667360]] [["rack/lib/rack/body_proxy.rb", 34, :T_ARRAY], [28230, 0, 26060, 0, 1, 1046800]] [["rails/activesupport/lib/active_support/notifications/fanout.rb", 55, :T_DATA], [28208, 0, 26042, 0, 1, 3034096]] [["rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [28204, 0, 26040, 0, 1, 1046080]] [["rails/activesupport/lib/active_support/callbacks.rb", 165, :T_DATA], [28200, 0, 26046, 0, 2, 3451800]] ```
This commit is contained in:
parent
83be86933d
commit
e334417b78
1 changed files with 2 additions and 3 deletions
|
@ -23,10 +23,9 @@ module ActionDispatch
|
|||
def match?(path)
|
||||
path = URI.parser.unescape(path)
|
||||
return false unless path.valid_encoding?
|
||||
path = Rack::Utils.clean_path_info path
|
||||
|
||||
paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"].map { |v|
|
||||
Rack::Utils.clean_path_info v
|
||||
}
|
||||
paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"]
|
||||
|
||||
if match = paths.detect { |p|
|
||||
path = File.join(@root, p)
|
||||
|
|
Loading…
Reference in a new issue