From f0f68e1b9629f6e098d8de3ed61a625c7d49e900 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 6 Jan 2025 12:36:05 +0800 Subject: [PATCH] Cleanup. --- Source/3rdParty/imgui/imconfig.h | 3 +-- Source/Common/Debug.cpp | 10 ++++------ Source/Common/Utils.cpp | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/3rdParty/imgui/imconfig.h b/Source/3rdParty/imgui/imconfig.h index 48d18724f..10582241c 100644 --- a/Source/3rdParty/imgui/imconfig.h +++ b/Source/3rdParty/imgui/imconfig.h @@ -176,5 +176,4 @@ namespace ImGui #define IMGUI_DISABLE_OBSOLETE_KEYIO #define IMGUI_DEFINE_MATH_OPERATORS - -#define IMGUI_DEBUG_PRINTF(_FMT,...) Dora::LogErrorThreaded(Dora::sprintf(_FMT, __VA_ARGS__)) +#define IMGUI_DEBUG_PRINTF(_FMT,...) Dora::LogErrorThreaded(Slice(Dora::sprintf(_FMT, __VA_ARGS__)).trimSpace().toString()) diff --git a/Source/Common/Debug.cpp b/Source/Common/Debug.cpp index 05a5e9793..058a07841 100644 --- a/Source/Common/Debug.cpp +++ b/Source/Common/Debug.cpp @@ -110,17 +110,15 @@ class Logger : public NonCopyable { } void log(spdlog::level::level_enum level, const std::string& msg) { - auto m = Slice(msg).trimSpace().toString(); - _logger->log(level, m); + _logger->log(level, msg); } void logAsync(spdlog::level::level_enum level, const std::string& msg) { - auto m = Slice(msg).trimSpace().toString(); if (Singleton::isDisposed()) { - _logger->log(level, m); + _logger->log(level, msg); } else { - _thread->run([this, level, m]() { - _logger->log(level, m); + _thread->run([this, level, msg]() { + _logger->log(level, msg); }); } } diff --git a/Source/Common/Utils.cpp b/Source/Common/Utils.cpp index 80776cadd..6353ad131 100644 --- a/Source/Common/Utils.cpp +++ b/Source/Common/Utils.cpp @@ -205,13 +205,13 @@ std::string sprintf(const char* fmt, ...) { va_end(args); if (n < 0) { - // vsnprintf 失败 + // vsnprintf failed return ""; } else if (n < size) { - // 格式化后的字符串已成功放入缓冲区 + // formatted string successfully placed in buffer return std::string(buffer.data(), n); } else { - // 缓冲区不足,需要重新分配 + // buffer is not enough, need to reallocate size = n + 1; buffer.resize(size);