diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-11-22 13:38:36 -0500 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-22 23:06:14 +0100 |
commit | c5bfc6abe4fd160814f09b02afe68d7f4e25e3d6 (patch) | |
tree | 8035f412348f6e281d05a08586c32b29d5a133dd | |
parent | 8154f4b816ea1bb2489fba1829ee99cb75fdf696 (diff) | |
download | rails-c5bfc6abe4fd160814f09b02afe68d7f4e25e3d6.tar.gz rails-c5bfc6abe4fd160814f09b02afe68d7f4e25e3d6.tar.bz2 rails-c5bfc6abe4fd160814f09b02afe68d7f4e25e3d6.zip |
string include method is 10x faster than creating
a new regex object every single time
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index f2ccf1784b..af7b62b863 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -174,7 +174,7 @@ module Mime # input: 'application' # returend value: [Mime::HTML, Mime::JS, Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::RSS, Mime::URL_ENCODED_FORM def parse_data_with_trailing_star(input) - keys = Mime::LOOKUP.keys.select{|k| Regexp.new(input).match(k)} + keys = Mime::LOOKUP.keys.select{|k| k.include?(input)} Mime::LOOKUP.select {|k,_| keys.include?(k)}.collect{|i| i[1]}.inject([]){|all,e| all.include?(e) ? all : all << e} end end |