1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-03 18:25:35 +00:00

perf: use std::string_view for compile-time UserAgent (#3161)

This commit is contained in:
Charles Kerr 2022-05-31 09:28:01 -05:00 committed by GitHub
parent 0097921f42
commit d1030b58b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -138,9 +138,9 @@ std::optional<std::string> tr_session::WebMediator::cookieFile() const
return std::string{ path };
}
std::optional<std::string> tr_session::WebMediator::userAgent() const
std::optional<std::string_view> tr_session::WebMediator::userAgent() const
{
return fmt::format(FMT_STRING("{:s}/{:s}"), TR_NAME, SHORT_VERSION_STRING);
return TR_NAME "/" SHORT_VERSION_STRING;
}
std::optional<std::string> tr_session::WebMediator::publicAddress() const

View file

@ -396,7 +396,7 @@ public:
[[nodiscard]] std::optional<std::string> cookieFile() const override;
[[nodiscard]] std::optional<std::string> publicAddress() const override;
[[nodiscard]] std::optional<std::string> userAgent() const override;
[[nodiscard]] std::optional<std::string_view> userAgent() const override;
[[nodiscard]] unsigned int clamp(int bandwidth_tag, unsigned int byte_count) const override;
void notifyBandwidthConsumed(int torrent_id, size_t byte_count) override;
// runs the tr_web::fetch response callback in the libtransmission thread

View file

@ -115,7 +115,7 @@ public:
}
// Return the preferred user aagent, or nullopt to not use one
[[nodiscard]] virtual std::optional<std::string> userAgent() const
[[nodiscard]] virtual std::optional<std::string_view> userAgent() const
{
return std::nullopt;
}