mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
perf: remove cpu bottleneck in tr_peerIo::write() (#4258)
This commit is contained in:
parent
d8327949ac
commit
0efb96124b
2 changed files with 7 additions and 5 deletions
|
@ -796,11 +796,8 @@ size_t tr_peerIo::getWriteBufferSpace(uint64_t now) const noexcept
|
|||
|
||||
void tr_peerIo::write(libtransmission::Buffer& buf, bool is_piece_data)
|
||||
{
|
||||
for (auto& ch : buf)
|
||||
{
|
||||
encrypt(1, &ch);
|
||||
}
|
||||
|
||||
auto [bytes, len] = buf.pullup();
|
||||
encrypt(len, bytes);
|
||||
outbuf_info.emplace_back(std::size(buf), is_piece_data);
|
||||
outbuf.add(buf);
|
||||
}
|
||||
|
|
|
@ -266,6 +266,11 @@ public:
|
|||
return iov;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::pair<std::byte*, size_t> pullup()
|
||||
{
|
||||
return { reinterpret_cast<std::byte*>(evbuffer_pullup(buf_.get(), -1)), size() };
|
||||
}
|
||||
|
||||
void commit(Iovec iov)
|
||||
{
|
||||
evbuffer_commit_space(buf_.get(), &iov, 1);
|
||||
|
|
Loading…
Reference in a new issue