]> Sergey Matveev's repositories - public-inbox.git/commitdiff
http: pass reference to Danga::Socket::write
authorEric Wong <e@80x24.org>
Sun, 22 May 2016 06:17:30 +0000 (06:17 +0000)
committerEric Wong <e@80x24.org>
Sun, 22 May 2016 07:28:19 +0000 (07:28 +0000)
This can avoid an expensive copy for big strings.

lib/PublicInbox/HTTP.pm

index 6576bf684931e6835ef9d07b4268e265a5ed8542..4eb14481fb667d219052f46c5461b974aca2889e 100644 (file)
@@ -200,7 +200,7 @@ sub response_write {
        my $alive = response_header_write($self, $env, $res);
 
        # middlewares such as Deflater may write empty strings
-       my $write = sub { $self->write($_[0]) if $_[0] ne '' };
+       my $write = sub { $self->write(\($_[0])) if $_[0] ne '' };
        my $close = sub {
                if ($alive) {
                        $self->event_write; # watch for readability if done