Skip to content

Commit c7620bb

Browse files
authored
Merge pull request rails#38914 from jasonhl/less-path-info
Reduce calls to get path info when finding routes
2 parents 887d4e1 + 9ec803b commit c7620bb

File tree

1 file changed

+4
-3
lines changed
  • actionpack/lib/action_dispatch/journey

1 file changed

+4
-3
lines changed

actionpack/lib/action_dispatch/journey/router.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ def filter_routes(path)
106106
end
107107

108108
def find_routes(req)
109-
routes = filter_routes(req.path_info).concat custom_routes.find_all { |r|
110-
r.path.match?(req.path_info)
109+
path_info = req.path_info
110+
routes = filter_routes(path_info).concat custom_routes.find_all { |r|
111+
r.path.match?(path_info)
111112
}
112113

113114
if req.head?
@@ -119,7 +120,7 @@ def find_routes(req)
119120
routes.sort_by!(&:precedence)
120121

121122
routes.map! { |r|
122-
match_data = r.path.match(req.path_info)
123+
match_data = r.path.match(path_info)
123124
path_parameters = {}
124125
match_data.names.each_with_index { |name, i|
125126
val = match_data[i + 1]

0 commit comments

Comments
 (0)