diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-08 15:57:07 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-08 16:14:47 -0700 |
commit | 376cccbdc1a39644dce234c39086349d81d907e7 (patch) | |
tree | 80edac363328d915f6648e254c4795cf16d4a7fc | |
parent | 8301969df9fd76bcde140f310300349b609e2b10 (diff) | |
download | rails-376cccbdc1a39644dce234c39086349d81d907e7.tar.gz rails-376cccbdc1a39644dce234c39086349d81d907e7.tar.bz2 rails-376cccbdc1a39644dce234c39086349d81d907e7.zip |
avoid allocations when there is no content type set
create a singleton content type that just has nils, so that we don't
have to allocate a content type object all the time.
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 8efc905384..71e7ebb838 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -318,6 +318,7 @@ module ActionDispatch # :nodoc: private ContentTypeHeader = Struct.new :mime_type, :charset + NullContentTypeHeader = ContentTypeHeader.new nil, nil def parse_content_type(content_type) if content_type @@ -325,7 +326,7 @@ module ActionDispatch # :nodoc: type = nil if type.empty? ContentTypeHeader.new(type, charset) else - ContentTypeHeader.new(nil, nil) + NullContentTypeHeader end end |