Skip to content

Commit

Permalink
fixed script, added concept sort
Browse files Browse the repository at this point in the history
  • Loading branch information
masaki committed Apr 21, 2009
1 parent 89b8894 commit fc2794c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/HTTP/Router.pm
Expand Up @@ -83,7 +83,12 @@ sub match {
push @match, $match;
}
if (@match > 1) {
# TODO: sort
# FIXME: sort
for my $match (@match) {
my @vars = $match->route->templates->variables;
$match = [ $match, scalar grep { exists $match->route->conditions->{$_} } @vars ];
}
@match = map { $_->[0] } sort { $b->[1] <=> $a->[1] } @match;
}
return wantarray ? @match : $match[0];
}
Expand Down
1 change: 1 addition & 0 deletions tools/benchmark_match.pl
Expand Up @@ -28,6 +28,7 @@ sub request {
my $conditions_request = request(path => '/account/login', method => 'POST');
my $validate_request = request(path => '/archives/2009');
my $resources_request = request(path => '/users/new', method => 'GET');
my $resource_request = request(path => '/admin/edit', method => 'GET');
my $var_resources = request(path => '/users/masaki', method => 'GET');

timethese(10000, {
Expand Down

0 comments on commit fc2794c

Please sign in to comment.