Replace x.sort_by!.select! with x.select!.sort_by!
The latter has the same speed as the former in the worst case and faster in general, because it is always better to sort less items. Unfortunately, `routes.select!{...}.sort_by!{...}` is not possible here because `select!` returns `nil`, so select! and sort! must be done in two steps.
This commit is contained in:
parent
edc0f27197
commit
8ee785a17f
@ -105,7 +105,8 @@ def find_routes req
|
||||
routes.concat get_routes_as_head(routes)
|
||||
end
|
||||
|
||||
routes.sort_by!(&:precedence).select! { |r| r.matches?(req) }
|
||||
routes.select! { |r| r.matches?(req) }
|
||||
routes.sort_by!(&:precedence)
|
||||
|
||||
routes.map! { |r|
|
||||
match_data = r.path.match(req.path_info)
|
||||
|
Loading…
Reference in New Issue
Block a user