From c3bc5864d0b8c56adee9544b64c9182d8d4eb206 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 6 Jun 2015 01:07:55 +0000 Subject: http: move response_start_sent into the C ext Combined with the previous commit to eliminate the `@socket' instance variable, this eliminates the last instance variable in the Unicorn::HttpRequest class. Eliminating the last instance variable avoids the creation of a internal hash table used for implementing the "generic" instance variables found in non-pure-Ruby classes. Method entry overhead remains the same. While this change doesn't do a whole lot for unicorn memory usage where the HttpRequest is a singleton, it helps other HTTP servers which rely on this code where thousands of clients may be connected. --- lib/unicorn/http_request.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/unicorn/http_request.rb') diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index f5c6b5b..9339bce 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -25,8 +25,6 @@ class Unicorn::HttpParser RACK_HIJACK_IO = "rack.hijack_io".freeze NULL_IO = StringIO.new("") - attr_accessor :response_start_sent - # :stopdoc: # A frozen format for this is about 15% faster # Drop these frozen strings when Ruby 2.2 becomes more prevalent, @@ -92,7 +90,7 @@ class Unicorn::HttpParser # detect if the socket is valid by writing a partial response: if @@check_client_connection && headers? - @response_start_sent = true + self.response_start_sent = true HTTP_RESPONSE_START.each { |c| socket.write(c) } end -- cgit v1.2.3-24-ge0c7