refactor: annotate nodiscard, constexpr, noexcept methods (#2879)

This commit is contained in:
Charles Kerr 2022-04-04 22:51:56 -05:00 committed by GitHub
parent a71f0c762d
commit 80dd460773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 112 additions and 116 deletions

View File

@ -63,22 +63,22 @@ private:
using trackers_t = std::vector<tracker_info>;
public:
[[nodiscard]] auto begin() const
[[nodiscard]] auto begin() const noexcept
{
return std::begin(trackers_);
}
[[nodiscard]] auto end() const
[[nodiscard]] auto end() const noexcept
{
return std::end(trackers_);
}
[[nodiscard]] bool empty() const
[[nodiscard]] bool empty() const noexcept
{
return std::empty(trackers_);
}
[[nodiscard]] size_t size() const
[[nodiscard]] size_t size() const noexcept
{
return std::size(trackers_);
}

View File

@ -91,7 +91,7 @@ namespace
struct StopsCompare
{
static int compare(tr_announce_request const* a, tr_announce_request const* b) // <=>
[[nodiscard]] static int compare(tr_announce_request const* a, tr_announce_request const* b) noexcept // <=>
{
// primary key: volume of data transferred
auto const ax = a->up + a->down;
@ -128,7 +128,7 @@ struct StopsCompare
return 0;
}
bool operator()(tr_announce_request const* a, tr_announce_request const* b) const // less than
[[nodiscard]] bool operator()(tr_announce_request const* a, tr_announce_request const* b) const noexcept // less than
{
return compare(a, b) < 0;
}
@ -331,7 +331,7 @@ struct tr_tier
return &trackers[*current_tracker_index_];
}
[[nodiscard]] bool needsToAnnounce(time_t now) const
[[nodiscard]] constexpr bool needsToAnnounce(time_t now) const
{
return !isAnnouncing && !isScraping && announceAt != 0 && announceAt <= now && !std::empty(announce_events);
}

View File

@ -113,12 +113,12 @@ public:
void setParent(Bandwidth* newParent);
[[nodiscard]] constexpr tr_priority_t getPriority() const
[[nodiscard]] constexpr tr_priority_t getPriority() const noexcept
{
return this->priority_;
}
constexpr void setPriority(tr_priority_t prio)
constexpr void setPriority(tr_priority_t prio) noexcept
{
this->priority_ = prio;
}
@ -126,7 +126,7 @@ public:
/**
* @brief clamps byte_count down to a number that this bandwidth will allow to be consumed
*/
[[nodiscard]] unsigned int clamp(tr_direction dir, unsigned int byte_count) const
[[nodiscard]] unsigned int clamp(tr_direction dir, unsigned int byte_count) const noexcept
{
return this->clamp(0, dir, byte_count);
}

View File

@ -13,13 +13,6 @@
#include "torrent.h"
#include "tr-assert.h"
uint64_t tr_completion::leftUntilDone() const
{
auto const size_when_done = sizeWhenDone();
auto const has_total = hasTotal();
return size_when_done - has_total;
}
uint64_t tr_completion::computeHasValid() const
{
uint64_t size = 0;
@ -167,7 +160,7 @@ void tr_completion::setBlocks(tr_bitfield blocks)
has_valid_.reset();
}
void tr_completion::setHasAll()
void tr_completion::setHasAll() noexcept
{
auto const total_size = block_info_->totalSize();

View File

@ -45,7 +45,7 @@ struct tr_completion
return blocks_;
}
[[nodiscard]] constexpr bool hasAll() const
[[nodiscard]] constexpr bool hasAll() const noexcept
{
return hasMetainfo() && blocks_.hasAll();
}
@ -60,7 +60,7 @@ struct tr_completion
return blocks_.count(span.begin, span.end) == span.end - span.begin;
}
[[nodiscard]] constexpr bool hasNone() const
[[nodiscard]] constexpr bool hasNone() const noexcept
{
return !hasMetainfo() || blocks_.hasNone();
}
@ -77,7 +77,10 @@ struct tr_completion
[[nodiscard]] uint64_t hasValid() const;
[[nodiscard]] uint64_t leftUntilDone() const;
[[nodiscard]] auto leftUntilDone() const
{
return sizeWhenDone() - hasTotal();
}
[[nodiscard]] constexpr double percentComplete() const
{
@ -118,7 +121,7 @@ struct tr_completion
}
}
void setHasAll();
void setHasAll() noexcept;
void setBlocks(tr_bitfield blocks);

View File

@ -308,27 +308,27 @@ public:
return Bps > 0;
}
[[nodiscard]] bool is_peer_choked() const override
[[nodiscard]] bool is_peer_choked() const noexcept override
{
return peer_is_choked_;
}
[[nodiscard]] bool is_peer_interested() const override
[[nodiscard]] bool is_peer_interested() const noexcept override
{
return peer_is_interested_;
}
[[nodiscard]] bool is_client_choked() const override
[[nodiscard]] bool is_client_choked() const noexcept override
{
return client_is_choked_;
}
[[nodiscard]] bool is_client_interested() const override
[[nodiscard]] bool is_client_interested() const noexcept override
{
return client_is_interested_;
}
[[nodiscard]] bool is_utp_connection() const override
[[nodiscard]] bool is_utp_connection() const noexcept override
{
return io->socket.type == TR_PEER_SOCKET_TYPE_UTP;
}
@ -358,7 +358,7 @@ public:
set_active(direction, calculate_active(direction));
}
[[nodiscard]] bool is_connection_older_than(time_t timestamp) const override
[[nodiscard]] bool is_connection_older_than(time_t timestamp) const noexcept override
{
return io->time_created < timestamp;
}

View File

@ -35,19 +35,19 @@ public:
virtual ~tr_peerMsgs() override = default;
virtual bool is_peer_choked() const = 0;
virtual bool is_peer_interested() const = 0;
virtual bool is_client_choked() const = 0;
virtual bool is_client_interested() const = 0;
[[nodiscard]] virtual bool is_peer_choked() const noexcept = 0;
[[nodiscard]] virtual bool is_peer_interested() const noexcept = 0;
[[nodiscard]] virtual bool is_client_choked() const noexcept = 0;
[[nodiscard]] virtual bool is_client_interested() const noexcept = 0;
virtual bool is_utp_connection() const = 0;
virtual bool is_encrypted() const = 0;
virtual bool is_incoming_connection() const = 0;
[[nodiscard]] virtual bool is_utp_connection() const noexcept = 0;
[[nodiscard]] virtual bool is_encrypted() const = 0;
[[nodiscard]] virtual bool is_incoming_connection() const = 0;
virtual bool is_active(tr_direction direction) const = 0;
[[nodiscard]] virtual bool is_active(tr_direction direction) const = 0;
virtual void update_active(tr_direction direction) = 0;
virtual bool is_connection_older_than(time_t time) const = 0;
[[nodiscard]] virtual bool is_connection_older_than(time_t time) const noexcept = 0;
virtual void cancel_block_request(tr_block_index_t block) = 0;

View File

@ -420,23 +420,23 @@ enum
*
* @return true if the specified string exists as a quark
*/
std::optional<tr_quark> tr_quark_lookup(std::string_view key);
[[nodiscard]] std::optional<tr_quark> tr_quark_lookup(std::string_view key);
/**
* Get the string that corresponds to the specified quark
*/
char const* tr_quark_get_string(tr_quark quark, size_t* len = nullptr);
[[nodiscard]] char const* tr_quark_get_string(tr_quark quark, size_t* len = nullptr);
/**
* Get the string view that corresponds to the specified quark.
*
* Note: this view is guaranteed to be zero-terminated at view[std::size(view)]
*/
std::string_view tr_quark_get_string_view(tr_quark quark);
[[nodiscard]] std::string_view tr_quark_get_string_view(tr_quark quark);
/**
* Create a new quark for the specified string. If a quark already
* exists for that string, it is returned so that no duplicates are
* created.
*/
tr_quark tr_quark_new(std::string_view);
[[nodiscard]] tr_quark tr_quark_new(std::string_view);

View File

@ -57,7 +57,7 @@ public:
{
return blockInfo().pieceLoc(piece, offset, length);
}
[[nodiscard]] constexpr auto blockSize(tr_block_index_t block) const
[[nodiscard]] constexpr auto blockSize(tr_block_index_t block) const noexcept
{
return blockInfo().blockSize(block);
}
@ -73,7 +73,7 @@ public:
{
return blockInfo().pieceSize();
}
[[nodiscard]] constexpr auto pieceSize(tr_piece_index_t piece) const
[[nodiscard]] constexpr auto pieceSize(tr_piece_index_t piece) const noexcept
{
return blockInfo().pieceSize(piece);
}
@ -82,55 +82,55 @@ public:
return blockInfo().totalSize();
}
[[nodiscard]] auto const& comment() const noexcept
[[nodiscard]] constexpr auto const& comment() const noexcept
{
return comment_;
}
[[nodiscard]] auto const& creator() const noexcept
[[nodiscard]] constexpr auto const& creator() const noexcept
{
return creator_;
}
[[nodiscard]] auto const& source() const noexcept
[[nodiscard]] constexpr auto const& source() const noexcept
{
return source_;
}
[[nodiscard]] auto fileCount() const noexcept
[[nodiscard]] constexpr auto fileCount() const noexcept
{
return std::size(files_);
}
[[nodiscard]] uint64_t fileSize(tr_file_index_t i) const;
[[nodiscard]] std::string const& fileSubpath(tr_file_index_t i) const;
void setFileSubpath(tr_file_index_t i, std::string_view subpath);
[[nodiscard]] uint64_t fileSize(tr_file_index_t i) const;
[[nodiscard]] auto const& isPrivate() const noexcept
[[nodiscard]] constexpr auto const& isPrivate() const noexcept
{
return is_private_;
}
[[nodiscard]] tr_sha1_digest_t const& pieceHash(tr_piece_index_t piece) const;
[[nodiscard]] auto const& dateCreated() const noexcept
[[nodiscard]] constexpr auto const& dateCreated() const noexcept
{
return date_created_;
}
[[nodiscard]] std::string benc() const;
[[nodiscard]] auto infoDictSize() const noexcept
[[nodiscard]] constexpr auto infoDictSize() const noexcept
{
return info_dict_size_;
}
[[nodiscard]] auto infoDictOffset() const noexcept
[[nodiscard]] constexpr auto infoDictOffset() const noexcept
{
return info_dict_offset_;
}
[[nodiscard]] auto piecesOffset() const noexcept
[[nodiscard]] constexpr auto piecesOffset() const noexcept
{
return pieces_offset_;
}

View File

@ -144,7 +144,7 @@ public:
return metainfo_.blockInfo();
}
[[nodiscard]] constexpr auto blockCount() const
[[nodiscard]] constexpr auto blockCount() const noexcept
{
return metainfo_.blockCount();
}
@ -160,7 +160,7 @@ public:
{
return metainfo_.pieceLoc(piece, offset, length);
}
[[nodiscard]] constexpr auto blockSize(tr_block_index_t block) const
[[nodiscard]] constexpr auto blockSize(tr_block_index_t block) const noexcept
{
return metainfo_.blockSize(block);
}
@ -168,19 +168,19 @@ public:
{
return metainfo_.blockSpanForPiece(piece);
}
[[nodiscard]] constexpr auto pieceCount() const
[[nodiscard]] constexpr auto pieceCount() const noexcept
{
return metainfo_.pieceCount();
}
[[nodiscard]] constexpr auto pieceSize() const
[[nodiscard]] constexpr auto pieceSize() const noexcept
{
return metainfo_.pieceSize();
}
[[nodiscard]] constexpr auto pieceSize(tr_piece_index_t piece) const
[[nodiscard]] constexpr auto pieceSize(tr_piece_index_t piece) const noexcept
{
return metainfo_.pieceSize(piece);
}
[[nodiscard]] constexpr auto totalSize() const
[[nodiscard]] constexpr auto totalSize() const noexcept
{
return metainfo_.totalSize();
}
@ -202,12 +202,12 @@ public:
return completion.hasMetainfo();
}
[[nodiscard]] auto hasAll() const
[[nodiscard]] auto hasAll() const noexcept
{
return completion.hasAll();
}
[[nodiscard]] auto hasNone() const
[[nodiscard]] auto hasNone() const noexcept
{
return completion.hasNone();
}
@ -257,7 +257,7 @@ public:
return completeness == TR_PARTIAL_SEED;
}
[[nodiscard]] tr_bitfield const& blocks() const
[[nodiscard]] tr_bitfield const& blocks() const noexcept
{
return completion.blocks();
}
@ -348,7 +348,7 @@ public:
/// METAINFO - FILES
[[nodiscard]] tr_file_index_t fileCount() const
[[nodiscard]] tr_file_index_t fileCount() const noexcept
{
return metainfo_.fileCount();
}
@ -398,17 +398,17 @@ public:
/// METAINFO - TRACKERS
[[nodiscard]] auto const& announceList() const
[[nodiscard]] auto const& announceList() const noexcept
{
return metainfo_.announceList();
}
[[nodiscard]] auto& announceList()
[[nodiscard]] auto& announceList() noexcept
{
return metainfo_.announceList();
}
[[nodiscard]] auto trackerCount() const
[[nodiscard]] auto trackerCount() const noexcept
{
return std::size(this->announceList());
}
@ -432,7 +432,7 @@ public:
/// METAINFO - WEBSEEDS
[[nodiscard]] auto webseedCount() const
[[nodiscard]] auto webseedCount() const noexcept
{
return metainfo_.webseedCount();
}
@ -449,32 +449,32 @@ public:
metainfo_.setName(name);
}
[[nodiscard]] auto const& name() const
[[nodiscard]] auto const& name() const noexcept
{
return metainfo_.name();
}
[[nodiscard]] auto const& infoHash() const
[[nodiscard]] auto const& infoHash() const noexcept
{
return metainfo_.infoHash();
}
[[nodiscard]] auto isPrivate() const
[[nodiscard]] auto isPrivate() const noexcept
{
return metainfo_.isPrivate();
}
[[nodiscard]] auto isPublic() const
[[nodiscard]] auto isPublic() const noexcept
{
return !this->isPrivate();
}
[[nodiscard]] auto const& infoHashString() const
[[nodiscard]] auto const& infoHashString() const noexcept
{
return metainfo_.infoHashString();
}
[[nodiscard]] auto dateCreated() const
[[nodiscard]] auto dateCreated() const noexcept
{
return metainfo_.dateCreated();
}
@ -499,27 +499,27 @@ public:
return metainfo_.magnet();
}
[[nodiscard]] auto const& comment() const
[[nodiscard]] auto const& comment() const noexcept
{
return metainfo_.comment();
}
[[nodiscard]] auto const& creator() const
[[nodiscard]] auto const& creator() const noexcept
{
return metainfo_.creator();
}
[[nodiscard]] auto const& source() const
[[nodiscard]] auto const& source() const noexcept
{
return metainfo_.source();
}
[[nodiscard]] auto infoDictSize() const
[[nodiscard]] auto infoDictSize() const noexcept
{
return metainfo_.infoDictSize();
}
[[nodiscard]] auto infoDictOffset() const
[[nodiscard]] auto infoDictOffset() const noexcept
{
return metainfo_.infoDictOffset();
}
@ -544,12 +544,12 @@ public:
return this->is_queued;
}
[[nodiscard]] constexpr auto queueDirection() const
[[nodiscard]] constexpr auto queueDirection() const noexcept
{
return this->isDone() ? TR_UP : TR_DOWN;
}
[[nodiscard]] auto allowsPex() const
[[nodiscard]] auto allowsPex() const noexcept
{
return this->isPublic() && this->session->isPexEnabled;
}
@ -589,7 +589,7 @@ public:
/** Return the mime-type (e.g. "audio/x-flac") that matches more of the
torrent's content than any other mime-type. */
std::string_view primaryMimeType() const;
[[nodiscard]] std::string_view primaryMimeType() const;
static constexpr std::string_view PartialFileSuffix = std::string_view{ ".part" };

View File

@ -67,13 +67,13 @@ char const* tr_strip_positional_args(char const* fmt);
#define TR_N_ELEMENTS(ary) (sizeof(ary) / sizeof(*(ary)))
std::string_view tr_get_mime_type_for_filename(std::string_view filename);
[[nodiscard]] std::string_view tr_get_mime_type_for_filename(std::string_view filename);
/**
* @brief Rich Salz's classic implementation of shell-style pattern matching for ?, \, [], and * characters.
* @return 1 if the pattern matches, 0 if it doesn't, or -1 if an error occured
*/
bool tr_wildmat(char const* text, char const* pattern) TR_GNUC_NONNULL(1, 2);
[[nodiscard]] bool tr_wildmat(char const* text, char const* pattern) TR_GNUC_NONNULL(1, 2);
/**
* @brief Loads a file and returns its contents.
@ -136,7 +136,7 @@ void tr_wait_msec(long int delay_milliseconds);
#include <sstream>
template<typename T>
std::optional<T> tr_parseNum(std::string_view& sv)
[[nodiscard]] std::optional<T> tr_parseNum(std::string_view& sv)
{
auto val = T{};
auto const str = std::string(std::data(sv), std::min(std::size(sv), size_t{ 64 }));
@ -157,7 +157,7 @@ std::optional<T> tr_parseNum(std::string_view& sv)
#include <charconv> // std::from_chars()
template<typename T>
std::optional<T> tr_parseNum(std::string_view& sv)
[[nodiscard]] std::optional<T> tr_parseNum(std::string_view& sv)
{
auto val = T{};
auto const* const begin_ch = std::data(sv);
@ -233,7 +233,7 @@ void tr_free(void* p);
* @param byteCount the number of bytes to copy
* @return a newly-allocated copy of `src' that can be freed with tr_free()
*/
void* tr_memdup(void const* src, size_t byteCount);
[[nodiscard]] void* tr_memdup(void const* src, size_t byteCount);
#define tr_new(struct_type, n_structs) (static_cast<struct_type*>(tr_malloc(sizeof(struct_type) * (size_t)(n_structs))))
@ -247,7 +247,7 @@ void* tr_memdup(void const* src, size_t byteCount);
* @param in is a void* so that callers can pass in both signed & unsigned without a cast
* @return a newly-allocated copy of `in' that can be freed with tr_free()
*/
char* tr_strdup(void const* in);
[[nodiscard]] char* tr_strdup(void const* in);
/**
* @brief like strcmp() but gracefully handles nullptr strings
@ -266,13 +266,13 @@ size_t tr_strlcpy(void* dst, void const* src, size_t siz);
/** @brief Convenience wrapper around strerorr() guaranteed to not return nullptr
@param errnum the error number to describe */
char const* tr_strerror(int errnum);
[[nodiscard]] char const* tr_strerror(int errnum);
/** @brief Returns true if the string ends with the specified case-insensitive suffix */
bool tr_str_has_suffix(char const* str, char const* suffix);
[[nodiscard]] bool tr_str_has_suffix(char const* str, char const* suffix);
template<typename T>
std::string tr_strlower(T in)
[[nodiscard]] std::string tr_strlower(T in)
{
auto out = std::string{ in };
std::for_each(std::begin(out), std::end(out), [](char& ch) { ch = std::tolower(ch); });
@ -280,7 +280,7 @@ std::string tr_strlower(T in)
}
template<typename T>
std::string tr_strupper(T in)
[[nodiscard]] std::string tr_strupper(T in)
{
auto out = std::string{ in };
std::for_each(std::begin(out), std::end(out), [](char& ch) { ch = std::toupper(ch); });
@ -292,7 +292,7 @@ std::string tr_strupper(T in)
***/
template<typename... T, typename std::enable_if_t<(std::is_convertible_v<T, std::string_view> && ...), bool> = true>
std::string tr_strvPath(T... args)
[[nodiscard]] std::string tr_strvPath(T... args)
{
auto setme = std::string{};
auto const n_args = sizeof...(args);
@ -313,7 +313,7 @@ std::string tr_strvPath(T... args)
}
template<typename... T, typename std::enable_if_t<(std::is_convertible_v<T, std::string_view> && ...), bool> = true>
std::string tr_strvJoin(T... args)
[[nodiscard]] std::string tr_strvJoin(T... args)
{
auto setme = std::string{};
auto const n = (std::size(std::string_view{ args }) + ...);
@ -326,27 +326,27 @@ std::string tr_strvJoin(T... args)
}
template<typename T>
constexpr bool tr_strvContains(std::string_view sv, T key) // c++23
[[nodiscard]] constexpr bool tr_strvContains(std::string_view sv, T key) // c++23
{
return sv.find(key) != sv.npos;
}
constexpr bool tr_strvStartsWith(std::string_view sv, char key) // c++20
[[nodiscard]] constexpr bool tr_strvStartsWith(std::string_view sv, char key) // c++20
{
return !std::empty(sv) && sv.front() == key;
}
constexpr bool tr_strvStartsWith(std::string_view sv, std::string_view key) // c++20
[[nodiscard]] constexpr bool tr_strvStartsWith(std::string_view sv, std::string_view key) // c++20
{
return std::size(key) <= std::size(sv) && sv.substr(0, std::size(key)) == key;
}
constexpr bool tr_strvEndsWith(std::string_view sv, std::string_view key) // c++20
[[nodiscard]] constexpr bool tr_strvEndsWith(std::string_view sv, std::string_view key) // c++20
{
return std::size(key) <= std::size(sv) && sv.substr(std::size(sv) - std::size(key)) == key;
}
constexpr bool tr_strvEndsWith(std::string_view sv, char key) // c++20
[[nodiscard]] constexpr bool tr_strvEndsWith(std::string_view sv, char key) // c++20
{
return !std::empty(sv) && sv.back() == key;
}
@ -370,9 +370,9 @@ constexpr bool tr_strvSep(std::string_view* sv, std::string_view* token, char de
return true;
}
std::string_view tr_strvStrip(std::string_view sv);
[[nodiscard]] std::string_view tr_strvStrip(std::string_view sv);
char* tr_strvDup(std::string_view) TR_GNUC_MALLOC;
[[nodiscard]] char* tr_strvDup(std::string_view) TR_GNUC_MALLOC;
std::string& tr_strvUtf8Clean(std::string_view cleanme, std::string& setme);
@ -382,7 +382,7 @@ std::string& tr_strvUtf8Clean(std::string_view cleanme, std::string& setme);
/** @brief return TR_RATIO_NA, TR_RATIO_INF, or a number in [0..1]
@return TR_RATIO_NA, TR_RATIO_INF, or a number in [0..1] */
double tr_getRatio(uint64_t numerator, uint64_t denominator);
[[nodiscard]] double tr_getRatio(uint64_t numerator, uint64_t denominator);
/**
* @brief Given a string like "1-4" or "1-4,6,9,14-51", this returns a
@ -392,7 +392,7 @@ double tr_getRatio(uint64_t numerator, uint64_t denominator);
*
* For example, "5-8" will return [ 5, 6, 7, 8 ] and setmeCount will be 4.
*/
std::vector<int> tr_parseNumberRange(std::string_view str);
[[nodiscard]] std::vector<int> tr_parseNumberRange(std::string_view str);
/**
* @brief truncate a double value at a given number of decimal places.
@ -408,16 +408,16 @@ std::vector<int> tr_parseNumberRange(std::string_view str);
* | These should match |
* +------------------------+
*/
double tr_truncd(double x, int decimal_places);
[[nodiscard]] double tr_truncd(double x, int decimal_places);
/* return a percent formatted string of either x.xx, xx.x or xxx */
std::string tr_strpercent(double x);
[[nodiscard]] std::string tr_strpercent(double x);
/**
* @param ratio the ratio to convert to a string
* @param infinity the string represntation of "infinity"
*/
std::string tr_strratio(double ratio, char const* infinity);
[[nodiscard]] std::string tr_strratio(double ratio, char const* infinity);
/** @brief Portability wrapper for localtime_r() that uses the system implementation if available */
struct tm* tr_localtime_r(time_t const* _clock, struct tm* _result);
@ -454,13 +454,13 @@ extern time_t __tr_current_time;
* to always be accurate. However, it is *much* faster when 100% accuracy
* isn't needed
*/
static inline time_t tr_time()
[[nodiscard]] static inline time_t tr_time() noexcept
{
return __tr_current_time;
}
/** @brief Private libtransmission function to update tr_time()'s counter */
constexpr void tr_timeUpdate(time_t now)
constexpr void tr_timeUpdate(time_t now) noexcept
{
__tr_current_time = now;
}

View File

@ -154,7 +154,7 @@ public:
queued_tasks_cv.notify_one();
}
[[nodiscard]] bool isClosed() const
[[nodiscard]] bool isClosed() const noexcept
{
return is_closed_;
}
@ -593,7 +593,7 @@ void tr_web::fetch(FetchOptions&& options)
impl_->fetch(std::move(options));
}
bool tr_web::isClosed() const
bool tr_web::isClosed() const noexcept
{
return impl_->isClosed();
}

View File

@ -83,7 +83,7 @@ public:
// True when tr_web is ready to be destroyed.
// Will never be true until after closeSoon() is called.
[[nodiscard]] bool isClosed() const;
[[nodiscard]] bool isClosed() const noexcept;
// If you want to give running tasks a chance to finish, call closeSoon()
// before destroying the tr_web object. Deleting the object will cancel

View File

@ -79,7 +79,7 @@ public:
class ConnectionLimiter
{
public:
void taskStarted()
constexpr void taskStarted() noexcept
{
++n_tasks;
}
@ -95,14 +95,14 @@ public:
--n_tasks;
}
void gotData()
constexpr void gotData() noexcept
{
TR_ASSERT(n_tasks > 0);
n_consecutive_failures = 0;
paused_until = 0;
}
[[nodiscard]] size_t slotsAvailable() const
[[nodiscard]] size_t slotsAvailable() const noexcept
{
if (isPaused())
{
@ -119,12 +119,12 @@ public:
}
private:
[[nodiscard]] bool isPaused() const
[[nodiscard]] bool isPaused() const noexcept
{
return paused_until > tr_time();
}
[[nodiscard]] size_t maxConnections() const
[[nodiscard]] constexpr size_t maxConnections() const noexcept
{
return n_consecutive_failures > 0 ? 1 : MaxConnections;
}