From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS8100 96.44.188.0/22 X-Spam-Status: No, score=-2.0 required=3.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_XBL shortcircuit=no autolearn=no version=3.3.2 X-Original-To: spew@80x24.org Received: from 80x24.org (manning2.torservers.net [96.44.189.101]) by dcvr.yhbt.net (Postfix) with ESMTP id 80DB0203EA for ; Tue, 30 Jun 2015 22:19:28 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH 3/3] http_response: reduce size of multi-line header path Date: Tue, 30 Jun 2015 22:19:21 +0000 Message-Id: <1435702761-9540-3-git-send-email-e@80x24.org> In-Reply-To: <1435702761-9540-1-git-send-email-e@80x24.org> References: <1435702761-9540-1-git-send-email-e@80x24.org> List-Id: This should save over 100 bytes of bytecode overhead due to reduced method dispatch points. The performance difference when this is actually hit could go either way depending on how String#<< and realloc(3) interact, but it's uncommon enough that nobody is expected to notice either way. --- lib/unicorn/http_response.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index ec8b7c8..c1aa738 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -39,7 +39,7 @@ module Unicorn::HttpResponse else if value.include?("\n".freeze) # avoiding blank, key-only cookies with /\n+/ - buf << value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" }.join + value.split(/\n+/).each { |v| buf << "#{key}: #{v}\r\n" } else buf << "#{key}: #{value}\r\n" end -- EW