fmt::format() optimization (fmt::unveil template)

This commit is contained in:
Nekotekina
2015-01-19 01:54:56 +03:00
parent 87f1a9d9dc
commit 0d28f378a7
20 changed files with 343 additions and 309 deletions
+6 -19
View File
@@ -126,24 +126,11 @@ static struct { inline operator Log::LogType() { return Log::LogType::SPU; } } S
static struct { inline operator Log::LogType() { return Log::LogType::ARMv7; } } ARMv7;
static struct { inline operator Log::LogType() { return Log::LogType::TTY; } } TTY;
inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text)
{
//another msvc bug makes this not work, uncomment this and delete everything else in this function when it's fixed
//Log::LogManager::getInstance().log({logType, severity, text})
void log_message(Log::LogType type, Log::LogSeverity sev, const char* text);
void log_message(Log::LogType type, Log::LogSeverity sev, const std::string& text);
Log::LogMessage msg{ type, sev, text };
Log::LogManager::getInstance().log(msg);
template<typename... Targs>
__noinline void log_message(Log::LogType type, Log::LogSeverity sev, const char* fmt, Targs... args)
{
log_message(type, sev, fmt::detail::format(fmt, strlen(fmt), fmt::do_unveil(args)...));
}
inline void log_message(Log::LogType type, Log::LogSeverity sev, const std::string& text)
{
Log::LogMessage msg{ type, sev, text };
Log::LogManager::getInstance().log(msg);
}
template<typename T, typename... Ts>
inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text, T arg, Ts... args)
{
Log::LogMessage msg{ type, sev, fmt::format(text, arg, args...) };
Log::LogManager::getInstance().log(msg);
}