diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-21 15:30:02 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-21 15:30:02 -0700 |
commit | 6486c7ac94268728c4255b420d36cb859cd3ea20 (patch) | |
tree | 4d3e31b16616c8ed997d4bdba017dba66f04a436 /actionpack/lib | |
parent | e35225e938820544f7e5b29475c2f8cc4da5cb1a (diff) | |
download | rails-6486c7ac94268728c4255b420d36cb859cd3ea20.tar.gz rails-6486c7ac94268728c4255b420d36cb859cd3ea20.tar.bz2 rails-6486c7ac94268728c4255b420d36cb859cd3ea20.zip |
drop array allocations on Mime::Type#=~
Synonyms are always a list of strings, and we have access to the
internal string representation, so we can avoid allocating new arrays.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 6a5b1a91e1..a4dfe72c63 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -318,9 +318,7 @@ to: def =~(mime_type) return false unless mime_type regexp = Regexp.new(Regexp.quote(mime_type.to_s)) - (@synonyms + [ self ]).any? do |synonym| - synonym.to_s =~ regexp - end + @synonyms.any? { |synonym| synonym.to_s =~ regexp } || @string =~ regexp end def html? |