output/httpd: avoid extra buffer copy if possible
This commit is contained in:
parent
2afe427ab3
commit
88793cbc1a
@ -169,6 +169,15 @@ HttpdOutput::ReadPage() noexcept
|
|||||||
unflushed_input = 0;
|
unflushed_input = 0;
|
||||||
|
|
||||||
if (r.data() != b.data()) {
|
if (r.data() != b.data()) {
|
||||||
|
if (size == 0 && r.size() >= sizeof(buffer) / 2)
|
||||||
|
/* if the returned memory area is
|
||||||
|
large (and nothing has been written
|
||||||
|
to the stack buffer yet), copy
|
||||||
|
right from the returned memory
|
||||||
|
area, avoiding the copy into the
|
||||||
|
buffer*/
|
||||||
|
return std::make_shared<Page>(r);
|
||||||
|
|
||||||
/* if the encoder did not write to the given
|
/* if the encoder did not write to the given
|
||||||
buffer but instead returned its own buffer,
|
buffer but instead returned its own buffer,
|
||||||
we need to copy it so we have a contiguous
|
we need to copy it so we have a contiguous
|
||||||
|
Loading…
Reference in New Issue
Block a user