Skip to content

Commit eb5a3bb

Browse files
Aleksoid1978v0lt
authored andcommitted
Util: оптимизация DLog. Вместо std::vformat используем std::format.
1 parent e6034ab commit eb5a3bb

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Source/Utils/Util.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,31 @@
77
#pragma once
88

99
#ifdef _DEBUG
10+
11+
inline void DebugLog(std::wstring_view str)
12+
{
13+
DbgLogInfo(LOG_TRACE, 3, str.data());
14+
}
15+
16+
inline void DebugLog(std::string_view str)
17+
{
18+
DbgLogInfo(LOG_TRACE, 3, str.data());
19+
}
20+
1021
template <typename... Args>
11-
inline void DebugLogFmt(std::wstring_view format, Args&& ...args)
22+
inline void DebugLog(std::wformat_string<Args...> fmt, Args&&... args)
1223
{
13-
if (sizeof...(Args)) {
14-
DbgLogInfo(LOG_TRACE, 3, std::vformat(format, std::make_wformat_args(args...)).c_str());
15-
} else {
16-
DbgLogInfo(LOG_TRACE, 3, format.data());
17-
}
24+
DbgLogInfo(LOG_TRACE, 3, std::format(fmt, std::forward<Args>(args)...).c_str());
1825
}
1926

2027
template <typename... Args>
21-
inline void DebugLogFmt(std::string_view format, Args&& ...args)
28+
inline void DebugLog(std::format_string<Args...> fmt, Args&&... args)
2229
{
23-
if (sizeof...(Args)) {
24-
DbgLogInfo(LOG_TRACE, 3, std::vformat(format, std::make_format_args(args...)).c_str());
25-
} else {
26-
DbgLogInfo(LOG_TRACE, 3, format.data());
27-
}
30+
DbgLogInfo(LOG_TRACE, 3, std::format(fmt, std::forward<Args>(args)...).c_str());
2831
}
2932

30-
#define DLog(...) DebugLogFmt(__VA_ARGS__)
31-
#define DLogIf(f,...) {if (f) DebugLogFmt(__VA_ARGS__);}
33+
#define DLog(...) DebugLog(__VA_ARGS__)
34+
#define DLogIf(f,...) {if (f) DebugLog(__VA_ARGS__);}
3235
#else
3336
#define DLog(...) __noop
3437
#define DLogIf(f,...) __noop

0 commit comments

Comments
 (0)