mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
refactor: make a few more methods constexpr (#5798)
This commit is contained in:
@@ -33,24 +33,28 @@ struct Handler
|
||||
class Context
|
||||
{
|
||||
public:
|
||||
Context(char const* stream_begin_in, tr_error** error_in)
|
||||
constexpr Context(char const* stream_begin_in, tr_error** error_in)
|
||||
: error{ error_in }
|
||||
, stream_begin_{ stream_begin_in }
|
||||
{
|
||||
}
|
||||
[[nodiscard]] std::pair<long, long> tokenSpan() const
|
||||
|
||||
[[nodiscard]] constexpr std::pair<long, long> tokenSpan() const
|
||||
{
|
||||
return std::make_pair(token_begin_ - stream_begin_, token_end_ - stream_begin_);
|
||||
return { token_begin_ - stream_begin_, token_end_ - stream_begin_ };
|
||||
}
|
||||
[[nodiscard]] auto raw() const
|
||||
|
||||
[[nodiscard]] constexpr auto raw() const
|
||||
{
|
||||
return std::string_view{ token_begin_, size_t(token_end_ - token_begin_) };
|
||||
}
|
||||
void setTokenSpan(char const* a, size_t len)
|
||||
|
||||
constexpr void setTokenSpan(char const* a, size_t len)
|
||||
{
|
||||
token_begin_ = a;
|
||||
token_end_ = token_begin_ + len;
|
||||
}
|
||||
|
||||
tr_error** error = nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
return is_enabled_;
|
||||
}
|
||||
|
||||
void setEnabled(bool is_enabled) noexcept
|
||||
constexpr void setEnabled(bool is_enabled) noexcept
|
||||
{
|
||||
is_enabled_ = is_enabled;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
user_data_ = user_data;
|
||||
}
|
||||
|
||||
void clear_callbacks()
|
||||
constexpr void clear_callbacks()
|
||||
{
|
||||
set_callbacks(nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user