perf: avoid vector temporary in announcer-udp (#4519)
This commit is contained in:
parent
2d2a5e1ad6
commit
eb27220662
|
@ -230,8 +230,8 @@ struct tau_announce_request
|
||||||
response.leechers = buf.toUint32();
|
response.leechers = buf.toUint32();
|
||||||
response.seeders = buf.toUint32();
|
response.seeders = buf.toUint32();
|
||||||
|
|
||||||
auto const contiguous = std::vector<std::byte>{ std::begin(buf), std::end(buf) };
|
auto const [bytes, n_bytes] = buf.pullup();
|
||||||
response.pex = tr_pex::from_compact_ipv4(std::data(contiguous), std::size(contiguous), nullptr, 0);
|
response.pex = tr_pex::from_compact_ipv4(bytes, n_bytes, nullptr, 0);
|
||||||
requestFinished();
|
requestFinished();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -383,8 +383,8 @@ struct tau_tracker
|
||||||
buf.addUint32(TAU_ACTION_CONNECT);
|
buf.addUint32(TAU_ACTION_CONNECT);
|
||||||
buf.addUint32(this->connection_transaction_id);
|
buf.addUint32(this->connection_transaction_id);
|
||||||
|
|
||||||
auto const contiguous = std::vector<std::byte>(std::begin(buf), std::end(buf));
|
auto const [bytes, n_bytes] = buf.pullup();
|
||||||
this->sendto(std::data(contiguous), std::size(contiguous));
|
this->sendto(bytes, n_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout_reqs)
|
if (timeout_reqs)
|
||||||
|
@ -544,8 +544,8 @@ private:
|
||||||
buf.addUint64(this->connection_id);
|
buf.addUint64(this->connection_id);
|
||||||
buf.add(payload, payload_len);
|
buf.add(payload, payload_len);
|
||||||
|
|
||||||
auto const contiguous = std::vector<std::byte>(std::begin(buf), std::end(buf));
|
auto const [bytes, n_bytes] = buf.pullup();
|
||||||
this->sendto(std::data(contiguous), std::size(contiguous));
|
this->sendto(bytes, n_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -80,7 +80,7 @@ size_t tr_peer_socket::try_write(Buffer& buf, size_t max, tr_error** error) cons
|
||||||
#ifdef WITH_UTP
|
#ifdef WITH_UTP
|
||||||
if (is_utp())
|
if (is_utp())
|
||||||
{
|
{
|
||||||
auto [data, datalen] = buf.pullup();
|
auto const [data, datalen] = buf.pullup();
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
auto const n_written = utp_write(handle.utp, data, std::min(datalen, max));
|
auto const n_written = utp_write(handle.utp, data, std::min(datalen, max));
|
||||||
|
|
Loading…
Reference in New Issue