From 376cccbdc1a39644dce234c39086349d81d907e7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 8 Sep 2015 15:57:07 -0700 Subject: 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. --- actionpack/lib/action_dispatch/http/response.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_dispatch/http') 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 -- cgit v1.2.3