aboutsummaryrefslogtreecommitdiff
path: root/src/common/logging/filter.cpp
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2025-10-01 23:18:37 +0200
committercrueter <crueter@eden-emu.dev>2025-10-01 23:18:37 +0200
commit76b5d6778ec6245979a9f6963616d7fadb814d76 (patch)
treed7658bb2129cdd4d7b2491727f0b92315fd47c1e /src/common/logging/filter.cpp
parent61adc85c4ba4d87c5dcf99212a94b9d9d4a6fe14 (diff)
[common/logging] faster logging by avoiding constructing unused strings/results (and filtering first) (#2603)
basically std::string would be invoked even when the logging was filtered, then destroyed instantly, invoking malloc/free and polluting mem arenas for no good reason Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2603 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/common/logging/filter.cpp')
-rw-r--r--src/common/logging/filter.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 4e3a614a45..813e812780 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -1,3 +1,6 @@
+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@@ -9,22 +12,20 @@ namespace Common::Log {
namespace {
template <typename It>
Level GetLevelByName(const It begin, const It end) {
- for (u8 i = 0; i < static_cast<u8>(Level::Count); ++i) {
- const char* level_name = GetLevelName(static_cast<Level>(i));
- if (Common::ComparePartialString(begin, end, level_name)) {
- return static_cast<Level>(i);
- }
+ for (u32 i = 0; i < u32(Level::Count); ++i) {
+ const char* level_name = GetLevelName(Level(i));
+ if (Common::ComparePartialString(begin, end, level_name))
+ return Level(i);
}
return Level::Count;
}
template <typename It>
Class GetClassByName(const It begin, const It end) {
- for (u8 i = 0; i < static_cast<u8>(Class::Count); ++i) {
- const char* level_name = GetLogClassName(static_cast<Class>(i));
- if (Common::ComparePartialString(begin, end, level_name)) {
- return static_cast<Class>(i);
- }
+ for (u32 i = 0; i < u32(Class::Count); ++i) {
+ const char* level_name = GetLogClassName(Class(i));
+ if (Common::ComparePartialString(begin, end, level_name))
+ return Class(i);
}
return Class::Count;
}
@@ -229,13 +230,12 @@ void Filter::ParseFilterString(std::string_view filter_view) {
}
bool Filter::CheckMessage(Class log_class, Level level) const {
- return static_cast<u8>(level) >=
- static_cast<u8>(class_levels[static_cast<std::size_t>(log_class)]);
+ return u8(level) >= u8(class_levels[std::size_t(log_class)]);
}
bool Filter::IsDebug() const {
return std::any_of(class_levels.begin(), class_levels.end(), [](const Level& l) {
- return static_cast<u8>(l) <= static_cast<u8>(Level::Debug);
+ return u8(l) <= u8(Level::Debug);
});
}