Skip to content

Commit f9bed92

Browse files
committed
Iterate custom_routes instead of allocating
This `#find_all` shows up as ~3% in a profile, this change eliminates it.
1 parent 4a90c7a commit f9bed92

File tree

1 file changed

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

1 file changed

+4
-2
lines changed

actionpack/lib/action_dispatch/journey/router.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ def filter_routes(path)
107107

108108
def find_routes(req)
109109
path_info = req.path_info
110-
routes = filter_routes(path_info).concat custom_routes.find_all { |r|
111-
r.path.match?(path_info)
110+
routes = filter_routes(path_info)
111+
112+
custom_routes.each { |r|
113+
routes << r if r.path.match?(path_info)
112114
}
113115

114116
if req.head?

0 commit comments

Comments
 (0)