提交 9ec803bb 编写于 作者: J jasonhl

Reduce calls to get path info when finding routes

上级 c1ccc6a0
...@@ -106,8 +106,9 @@ def filter_routes(path) ...@@ -106,8 +106,9 @@ def filter_routes(path)
end end
def find_routes(req) def find_routes(req)
routes = filter_routes(req.path_info).concat custom_routes.find_all { |r| path_info = req.path_info
r.path.match?(req.path_info) routes = filter_routes(path_info).concat custom_routes.find_all { |r|
r.path.match?(path_info)
} }
if req.head? if req.head?
...@@ -119,7 +120,7 @@ def find_routes(req) ...@@ -119,7 +120,7 @@ def find_routes(req)
routes.sort_by!(&:precedence) routes.sort_by!(&:precedence)
routes.map! { |r| routes.map! { |r|
match_data = r.path.match(req.path_info) match_data = r.path.match(path_info)
path_parameters = {} path_parameters = {}
match_data.names.each_with_index { |name, i| match_data.names.each_with_index { |name, i|
val = match_data[i + 1] val = match_data[i + 1]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册