about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTP.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 02:52:12 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:26 +0000
commit676f13ac53bf96eab869514fe9fafcc0169874ab (patch)
tree39220513165c318dee7695e0f276e382470d1535 /lib/PublicInbox/HTTP.pm
parentf6c9b3da9cf87cfbde7b95772de6b337ba46ef68 (diff)
downloadpublic-inbox-676f13ac53bf96eab869514fe9fafcc0169874ab.tar.gz
http: favor DS->write(strref) when reasonable
This can avoid large memory copies when strings can't be
copy-on-write and saves us the trouble of creating new
refs in the code.
Diffstat (limited to 'lib/PublicInbox/HTTP.pm')
-rw-r--r--lib/PublicInbox/HTTP.pm10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 9a43069f..4f1f88fe 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -209,7 +209,7 @@ sub response_header_write {
         if (($len || $chunked) && $env->{REQUEST_METHOD} ne 'HEAD') {
                 more($self, $h);
         } else {
-                $self->write($h);
+                $self->write(\$h);
         }
         $alive;
 }
@@ -222,7 +222,7 @@ sub chunked_wcb ($) {
                 more($self, sprintf("%x\r\n", bytes::length($_[0])));
                 more($self, $_[0]);
 
-                # use $self->write("\n\n") if you care about real-time
+                # use $self->write(\"\n\n") if you care about real-time
                 # streaming responses, public-inbox WWW does not.
                 more($self, "\r\n");
         }
@@ -248,7 +248,7 @@ sub response_done_cb ($$) {
         sub {
                 my $env = $self->{env};
                 $self->{env} = undef;
-                $self->write("0\r\n\r\n") if $alive == 2;
+                $self->write(\"0\r\n\r\n") if $alive == 2;
                 $self->write(sub{$alive ? next_request($self) : $self->close});
         }
 }
@@ -330,7 +330,7 @@ sub more ($$) {
                         return $self->write(substr($_[1], $n, $nlen));
                 }
         }
-        $self->write($_[1]);
+        $self->write(\($_[1]));
 }
 
 sub input_prepare {
@@ -467,7 +467,7 @@ sub read_input_chunked { # unlikely...
 sub quit {
         my ($self, $status) = @_;
         my $h = "HTTP/1.1 $status " . status_message($status) . "\r\n\r\n";
-        $self->write($h);
+        $self->write(\$h);
         $self->close;
 }