Conversation
066383c to
10cceb5
Compare
| DebugCount::set("last image gc: expired", numExpired); | ||
| DebugCount::set("last image gc: eligible", eligible); | ||
| DebugCount::set("last image gc: left after gc", this->allImages_.size()); | ||
| DebugCount::set(DebugObject::LastImageGcExpired, numExpired); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
DebugCount::set(DebugObject::LastImageGcExpired, numExpired);
^| DebugCount::set("last image gc: eligible", eligible); | ||
| DebugCount::set("last image gc: left after gc", this->allImages_.size()); | ||
| DebugCount::set(DebugObject::LastImageGcExpired, numExpired); | ||
| DebugCount::set(DebugObject::LastImageGcEligible, eligible); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
DebugCount::set(DebugObject::LastImageGcEligible, eligible);
^| DebugCount::set("last image gc: left after gc", this->allImages_.size()); | ||
| DebugCount::set(DebugObject::LastImageGcExpired, numExpired); | ||
| DebugCount::set(DebugObject::LastImageGcEligible, eligible); | ||
| DebugCount::set(DebugObject::LastImageGcLeft, this->allImages_.size()); |
There was a problem hiding this comment.
warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int64_t' (aka 'long') is implementation-defined [bugprone-narrowing-conversions]
DebugCount::set(DebugObject::LastImageGcLeft, this->allImages_.size());
^|
|
||
| namespace chatterino { | ||
|
|
||
| void DebugCount::set(DebugObject target, const int64_t &amount) |
There was a problem hiding this comment.
warning: chatterino::DebugCount::set: Pass small and trivially-copyable type by value (const int64_t & amount) [clazy-function-args-by-value]
| void DebugCount::set(DebugObject target, const int64_t &amount) | |
| void DebugCount::set(DebugObject target, int64_t amount) |
src/util/DebugCount.hpp:60:
- static void set(DebugObject target, const int64_t &amount);
+ static void set(DebugObject target, int64_t amount);| } | ||
|
|
||
| void DebugCount::decrease(const QString &name, const int64_t &amount) | ||
| void DebugCount::decrease(DebugObject target, const int64_t &amount) |
There was a problem hiding this comment.
warning: chatterino::DebugCount::decrease: Pass small and trivially-copyable type by value (const int64_t & amount) [clazy-function-args-by-value]
| void DebugCount::decrease(DebugObject target, const int64_t &amount) | |
| void DebugCount::decrease(DebugObject target, int64_t amount) |
src/util/DebugCount.hpp:68:
- static void decrease(DebugObject target, const int64_t &amount);
+ static void decrease(DebugObject target, int64_t amount);|
|
||
| namespace chatterino { | ||
|
|
||
| enum class DebugObject : size_t { |
There was a problem hiding this comment.
warning: enum 'DebugObject' uses a larger base type ('size_t' (aka 'unsigned long'), size: 8 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
enum class DebugObject : size_t {
^| case chatterino::DebugObject::MessageThread: | ||
| case chatterino::DebugObject::Message: | ||
| default: | ||
| return default_tag; |
There was a problem hiding this comment.
warning: Using copy-ctor but class magic_enum::customize::customize_t has a trivial copy-ctor but non trivial assign operator [clazy-rule-of-two-soft]
return default_tag;
^
pajlada
left a comment
There was a problem hiding this comment.
Feel free to apply the clang-tidy suggestions about const& params on the set calls
|
|
||
| static void set(const QString &name, const int64_t &amount); | ||
| template <DebugObject target> | ||
| class AutoDebugCount |
There was a problem hiding this comment.
Could we hold off on the AutoDebugCount implementation for a follow-up PR?
|
|
||
| // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) | ||
| UniqueAccess<std::map<QString, Count>> COUNTS; | ||
| UniqueAccess<std::array<Count, static_cast<size_t>(DebugObject::Count)>> COUNTS; |
There was a problem hiding this comment.
Can make use of magic_enum's enum_size function here, which means we don't have to keep Count
| }; | ||
|
|
||
| } // namespace chatterino | ||
| template <> |
There was a problem hiding this comment.
new line
| template <> | |
| template <> |
|
magic_enum didn't really like me when I tried that and produced
megabytes of error messages. I CBA to debug why that pile of templates
dislikes me today.
W dniu 24.01.2026 o 13:00, pajlada pisze:
… Can make use of magic_enum's enum_size function here, which means we don't have to keep `Count`
|
68dceef to
65eb043
Compare
| static void increase(DebugObject target, int64_t amount); | ||
| static void increase(DebugObject target) |
There was a problem hiding this comment.
The amount could default to 1, then you won't need an additional overload. Same for the decrease method.
Switching to enums gives us a nice way to implement a base template that increments and decrements the DebugCount on (de)construction.
This fixes issues with Lua HTTP objects showing negative amounts, I don't believe we had an issue for that.I undid the AutoDebugCount changes.