From f1525dac115cea40ec41b4f9e267e011be8da22e Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 28 Dec 2016 11:35:43 -0800 Subject: Optimize Journey::Route#score Scoring routes based on constraints repeated many type conversions that could be performed in the outer loop. Determinations of score and fitness also used Array operations that required allocations. Against my benchmark with a large routeset, this reduced object allocations by over 30x and wall time by over 3x. --- actionpack/test/journey/route_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test/journey') diff --git a/actionpack/test/journey/route_test.rb b/actionpack/test/journey/route_test.rb index d2a8163ffb..8fd73970b8 100644 --- a/actionpack/test/journey/route_test.rb +++ b/actionpack/test/journey/route_test.rb @@ -96,7 +96,7 @@ module ActionDispatch path = Path::Pattern.from_string "/:controller(/:action(/:id))(.:format)" generic = Route.build "name", nil, path, constraints, [], {} - knowledge = { id: 20, controller: "pages", action: "show" } + knowledge = { "id" => true, "controller" => true, "action" => true } routes = [specific, generic] -- cgit v1.2.3