From 1ef55a9a36e2780fe1c72e87232f5097fb0837b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 31 Aug 2025 14:49:18 +0200 Subject: [PATCH] Delete unused code, inline a tiny function --- Common/StringUtils.cpp | 41 ++--------------------------------------- Common/StringUtils.h | 9 ++++----- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index fea681cf05..3f119d3ac1 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -64,10 +64,6 @@ size_t truncate_cpy(char *dest, size_t destSize, std::string_view src) { } } -const char* safe_string(const char* s) { - return s ? s : "(null)"; -} - long parseHexLong(const std::string &s) { long value = 0; @@ -187,38 +183,6 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar } } -bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename, std::string* _pExtension) -{ - if (full_path.empty()) - return false; - - size_t dir_end = full_path.find_last_of("/" - // windows needs the : included for something like just "C:" to be considered a directory -#ifdef _WIN32 - ":" -#endif - ); - if (std::string::npos == dir_end) - dir_end = 0; - else - dir_end += 1; - - size_t fname_end = full_path.rfind('.'); - if (fname_end < dir_end || std::string::npos == fname_end) - fname_end = full_path.size(); - - if (_pPath) - *_pPath = full_path.substr(0, dir_end); - - if (_pFilename) - *_pFilename = full_path.substr(dir_end, fname_end - dir_end); - - if (_pExtension) - *_pExtension = full_path.substr(fname_end); - - return true; -} - std::string LineNumberString(const std::string &str) { std::stringstream input(str); std::stringstream output; @@ -291,7 +255,7 @@ void DataToHexString(const uint8_t *data, size_t size, std::string *output, bool buffer.TakeAll(output); } -void DataToHexString(int indent, uint32_t startAddr, const uint8_t* data, size_t size, std::string* output) { +void DataToHexString(int indent, uint32_t startAddr, const uint8_t* data, size_t size, std::string *output) { Buffer buffer; size_t i = 0; for (; i < size; i++) { @@ -321,8 +285,7 @@ void DataToHexString(int indent, uint32_t startAddr, const uint8_t* data, size_t buffer.TakeAll(output); } -std::string StringFromFormat(const char* format, ...) -{ +std::string StringFromFormat(const char* format, ...) { va_list args; std::string temp; #ifdef _WIN32 diff --git a/Common/StringUtils.h b/Common/StringUtils.h index 8e87d66387..585e9bb773 100644 --- a/Common/StringUtils.h +++ b/Common/StringUtils.h @@ -90,7 +90,7 @@ enum class StringRestriction { std::string SanitizeString(std::string_view username, StringRestriction restriction, int minLength = 0, int maxLength = -1); void DataToHexString(const uint8_t *data, size_t size, std::string *output, bool lineBreaks = true); -void DataToHexString(int indent, uint32_t startAddr, const uint8_t* data, size_t size, std::string* output); +void DataToHexString(int indent, uint32_t startAddr, const uint8_t* data, size_t size, std::string *output); std::string StringFromFormat(const char* format, ...); std::string StringFromInt(int value); @@ -131,7 +131,9 @@ inline size_t truncate_cpy(char(&out)[Count], std::string_view src) { return truncate_cpy(out, Count, src); } -const char* safe_string(const char* s); +inline const char *safe_string(const char *s) { + return s ? s : "(null)"; +} long parseHexLong(const std::string &s); long parseLong(std::string s); @@ -147,9 +149,6 @@ inline void CharArrayFromFormat(char (& out)[Count], const char* format, ...) va_end(args); } -// "C:/Windows/winhelp.exe" to "C:/Windows/", "winhelp", ".exe" -bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _pFilename, std::string* _pExtension); - void MakeUnique(std::vector &vec); // Replaces %1, %2, %3 in format with arg1, arg2, arg3.