rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: rack-devel@googlegroups.com
Subject: [PATCH 2/5] deflater: avoid wasting an ivar slot on @closed
Date: Thu, 29 Jun 2017 02:19:12 +0000	[thread overview]
Message-ID: <20170629021915.22517-3-e@80x24.org> (raw)
In-Reply-To: <20170629021915.22517-1-e@80x24.org>

We can merely set the @body to nil ensure we do not call close
on the @body, twice.  Saving an ivar slot can save 8 bytes
per object at minimum, and this makes me feel more comfortable
about using another ivar for the next commit.
---
 lib/rack/deflater.rb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/rack/deflater.rb b/lib/rack/deflater.rb
index 9b798ba..d575adf 100644
--- a/lib/rack/deflater.rb
+++ b/lib/rack/deflater.rb
@@ -70,7 +70,6 @@ module Rack
       def initialize(body, mtime)
         @body = body
         @mtime = mtime
-        @closed = false
       end
 
       def each(&block)
@@ -91,9 +90,8 @@ module Rack
       end
 
       def close
-        return if @closed
-        @closed = true
         @body.close if @body.respond_to?(:close)
+        @body = nil
       end
     end
 
-- 
EW

-- 

--- 
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2017-06-29  2:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  2:19 [PATCH 0/5] deflater: tiny optimizations + 1 new feature Eric Wong
2017-06-29  2:19 ` [PATCH 1/5] deflater: rely on frozen_string_literal Eric Wong
2017-06-29  2:19 ` Eric Wong [this message]
2017-06-29  2:19 ` [PATCH 3/5] deflater: support "sync: false" option Eric Wong
2017-06-29  2:19 ` [PATCH 4/5] deflater: additional mtime tests Eric Wong
2017-06-29  2:19 ` [PATCH 5/5] deflater: reduce live Time objects Eric Wong
2017-07-24  1:33 ` [PATCH 0/5] deflater: tiny optimizations + 1 new feature Eric Wong
2017-07-25  1:11   ` Rafael Mendonça França

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170629021915.22517-3-e@80x24.org \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).