From 24ef76bfeeb64158ae20034ac30c1a2cee23e364 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 19 Jul 2024 14:01:04 +1000 Subject: [PATCH] StringUtil: Purge StdStringFromFormat() --- src/common/string_util.cpp | 33 --------------------------------- src/common/string_util.h | 5 ----- 2 files changed, 38 deletions(-) diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index d219f4450..aee18ed06 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -13,39 +13,6 @@ #include "windows_headers.h" #endif -std::string StringUtil::StdStringFromFormat(const char* format, ...) -{ - std::va_list ap; - va_start(ap, format); - std::string ret = StdStringFromFormatV(format, ap); - va_end(ap); - return ret; -} - -std::string StringUtil::StdStringFromFormatV(const char* format, std::va_list ap) -{ - std::va_list ap_copy; - va_copy(ap_copy, ap); - -#ifdef _WIN32 - int len = _vscprintf(format, ap_copy); -#else - int len = std::vsnprintf(nullptr, 0, format, ap_copy); -#endif - va_end(ap_copy); - - std::string ret; - - // If an encoding error occurs, len is -1. Which we definitely don't want to resize to. - if (len > 0) - { - ret.resize(len); - std::vsnprintf(ret.data(), ret.size() + 1, format, ap); - } - - return ret; -} - bool StringUtil::WildcardMatch(const char* subject, const char* mask, bool case_sensitive /*= true*/) { if (case_sensitive) diff --git a/src/common/string_util.h b/src/common/string_util.h index 1ed7f49c8..3b8b2dce9 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -4,7 +4,6 @@ #pragma once #include "types.h" #include -#include #include #include #include @@ -27,10 +26,6 @@ namespace StringUtil { -/// Constructs a std::string from a format string. -std::string StdStringFromFormat(const char* format, ...) printflike(1, 2); -std::string StdStringFromFormatV(const char* format, std::va_list ap); - /// Checks if a wildcard matches a search string. bool WildcardMatch(const char* subject, const char* mask, bool case_sensitive = true);