Skip to content

Commit

Permalink
Use break instead of next in AD::Journey::Formatter#match_route
Browse files Browse the repository at this point in the history
The array is sorted in descending order, so there is no point in
iterating further if we met a negative item - all the rest will be
negative too.
  • Loading branch information
Viktar Basharymau committed May 22, 2014
1 parent 66dd216 commit eba8b70
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/journey/formatter.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def match_route(name, options)
hash = routes.group_by { |_, r| r.score(options) } hash = routes.group_by { |_, r| r.score(options) }


hash.keys.sort.reverse_each do |score| hash.keys.sort.reverse_each do |score|
next if score < 0 break if score < 0


hash[score].sort_by { |i, _| i }.each do |_, route| hash[score].sort_by { |i, _| i }.each do |_, route|
yield route yield route
Expand Down

0 comments on commit eba8b70

Please sign in to comment.