Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Stop as soon as we get a match

Instead of building a list of all the matches, and then picking off
the first one, just stop as soon as we find a match.
  • Loading branch information...
1 parent 9d0243b commit 60377392e5d368f4a2e7e0654030fe5e055cdd64 @tomhughes committed
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/http_accept_language/parser.rb
4 lib/http_accept_language/parser.rb
@@ -55,10 +55,10 @@ def preferred_language_from(array)
# request.compatible_language_from I18n.available_locales
def compatible_language_from(available_languages)
- do |preferred|
+ user_preferred_languages.find do |preferred|
available_languages.find { |available| available.to_s == preferred.to_s } ||
available_languages.find { |available| available.to_s =~ /^#{Regexp.escape(preferred.to_s)}-/ }
- end.compact.first
+ end
# Returns a supplied list of available locals without any extra application info

0 comments on commit 6037739

Please sign in to comment.
Something went wrong with that request. Please try again.