Skip to content

Commit

Permalink
Use memcpy to avoid putting one byte at a time when copying blocks
Browse files Browse the repository at this point in the history
`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 <[email protected]>
  • Loading branch information
djarek authored and vinniefalco committed Oct 7, 2019
1 parent 85ab7a3 commit 962f01e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/boost/beast/zlib/detail/deflate_stream.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 962f01e

Please sign in to comment.