Permalink
Browse files

Reduce the amount of temp objects

  • Loading branch information...
spastorino committed Jul 23, 2012
1 parent 530024a commit 3a83781922d040b3233435666f7c4097fbe7404b
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/journey/router.rb
View
@@ -125,15 +125,18 @@ def filter_routes path
def find_routes env
req = request_class.new env
- routes = filter_routes(req.path_info) + custom_routes.find_all { |r|
+ routes = filter_routes(req.path_info).concat custom_routes.find_all { |r|
r.path.match(req.path_info)
}
routes.concat head_routes(routes)
- routes.sort_by(&:precedence).find_all { |r|
+ routes.sort_by!(&:precedence).select! { |r|
r.constraints.all? { |k,v| v === req.send(k) } &&
r.verb === req.request_method
- }.reject { |r| req.ip && !(r.ip === req.ip) }.map { |r|
+ }
+ routes.reject! { |r| req.ip && !(r.ip === req.ip) }
+
+ routes.map! { |r|
match_data = r.path.match(req.path_info)
match_names = match_data.names.map { |n| n.to_sym }
match_values = match_data.captures.map { |v| v && Utils.unescape_uri(v) }

0 comments on commit 3a83781

Please sign in to comment.