perf: buffer iterators (#4220)
This commit is contained in:
parent
191c6d1402
commit
43c57fb02a
|
@ -788,16 +788,13 @@ size_t tr_peerIo::getWriteBufferSpace(uint64_t now) const noexcept
|
|||
|
||||
void tr_peerIo::write(libtransmission::Buffer& buf, bool is_piece_data)
|
||||
{
|
||||
auto const n_bytes = std::size(buf);
|
||||
|
||||
auto const old_size = std::size(outbuf);
|
||||
outbuf.add(buf);
|
||||
for (auto iter = std::begin(outbuf) + old_size, end = std::end(outbuf); iter != end; ++iter)
|
||||
for (auto& ch : buf)
|
||||
{
|
||||
encrypt(1, &*iter);
|
||||
encrypt(1, &ch);
|
||||
}
|
||||
|
||||
outbuf_info.emplace_back(n_bytes, is_piece_data);
|
||||
outbuf_info.emplace_back(std::size(buf), is_piece_data);
|
||||
outbuf.add(buf);
|
||||
}
|
||||
|
||||
void tr_peerIo::writeBytes(void const* bytes, size_t n_bytes, bool is_piece_data)
|
||||
|
|
|
@ -81,7 +81,7 @@ class Filter
|
|||
public:
|
||||
void decryptInit(bool is_incoming, DH const&, tr_sha1_digest_t const& info_hash);
|
||||
|
||||
void decrypt(size_t buf_len, void* buf)
|
||||
constexpr void decrypt(size_t buf_len, void* buf)
|
||||
{
|
||||
if (dec_active_)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
void encryptInit(bool is_incoming, DH const&, tr_sha1_digest_t const& info_hash);
|
||||
|
||||
void encrypt(size_t buf_len, void* buf)
|
||||
constexpr void encrypt(size_t buf_len, void* buf)
|
||||
{
|
||||
if (enc_active_)
|
||||
{
|
||||
|
|
|
@ -42,14 +42,14 @@ public:
|
|||
setOffset(offset);
|
||||
}
|
||||
|
||||
[[nodiscard]] value_type& operator*() noexcept
|
||||
[[nodiscard]] constexpr value_type& operator*() noexcept
|
||||
{
|
||||
return reinterpret_cast<value_type*>(iov_.iov_base)[iov_offset_];
|
||||
return static_cast<value_type*>(iov_.iov_base)[iov_offset_];
|
||||
}
|
||||
|
||||
[[nodiscard]] value_type operator*() const noexcept
|
||||
[[nodiscard]] constexpr value_type operator*() const noexcept
|
||||
{
|
||||
return reinterpret_cast<value_type*>(iov_.iov_base)[iov_offset_];
|
||||
return static_cast<value_type*>(iov_.iov_base)[iov_offset_];
|
||||
}
|
||||
|
||||
[[nodiscard]] Iterator operator+(size_t n_bytes)
|
||||
|
@ -172,32 +172,32 @@ public:
|
|||
|
||||
[[nodiscard]] auto begin() noexcept
|
||||
{
|
||||
return Iterator(buf_.get(), 0U);
|
||||
return Iterator{ buf_.get(), 0U };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto end() noexcept
|
||||
{
|
||||
return Iterator(buf_.get(), size());
|
||||
return Iterator{ buf_.get(), size() };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto begin() const noexcept
|
||||
{
|
||||
return Iterator(buf_.get(), 0U);
|
||||
return Iterator{ buf_.get(), 0U };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto end() const noexcept
|
||||
{
|
||||
return Iterator(buf_.get(), size());
|
||||
return Iterator{ buf_.get(), size() };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto cbegin() const noexcept
|
||||
{
|
||||
return Iterator(buf_.get(), 0U);
|
||||
return Iterator{ buf_.get(), 0U };
|
||||
}
|
||||
|
||||
[[nodiscard]] auto cend() const noexcept
|
||||
{
|
||||
return Iterator(buf_.get(), size());
|
||||
return Iterator{ buf_.get(), size() };
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in New Issue