From d41b7c23288ebe8c2911feb9ffc26b218d539b53 Mon Sep 17 00:00:00 2001 From: Damian Jarek Date: Mon, 9 Sep 2019 03:14:39 +0200 Subject: [PATCH] Use memcpy to avoid putting one byte at a time when copying blocks `memcpy` is likely to be faster than the naive method due to the possibility of use of vector instructions and copying more than a byte at a time. Signed-off-by: Damian Jarek --- include/boost/beast/zlib/detail/deflate_stream.ipp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/boost/beast/zlib/detail/deflate_stream.ipp b/include/boost/beast/zlib/detail/deflate_stream.ipp index 470c7d0d..8ad68262 100644 --- a/include/boost/beast/zlib/detail/deflate_stream.ipp +++ b/include/boost/beast/zlib/detail/deflate_stream.ipp @@ -1298,9 +1298,8 @@ copy_block( put_short((std::uint16_t)len); put_short((std::uint16_t)~len); } - // VFALCO Use memcpy? - while (len--) - put_byte(*buf++); + std::memcpy(&pending_buf_[pending_], buf, len); + pending_ += len; } //------------------------------------------------------------------------------