From 73d043fde5e4367fa4f86de062b1048a1535cbe0 Mon Sep 17 00:00:00 2001 From: phosit Date: Mon, 24 Aug 2026 13:34:37 +0200 Subject: [PATCH] Remove CStr::Pad It was only used once. It can be replaced by fmt. --- source/ps/CStr.cpp | 31 ------------------------------- source/ps/CStr.h | 11 +---------- source/ps/ProfileViewer.cpp | 5 +++-- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index d9f58656f5..9a961002d8 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -434,37 +434,6 @@ CStr CStr::Trim(PS_TRIM_MODE mode) const return substr(left, right - left + 1); } -CStr CStr::Pad(PS_TRIM_MODE mode, size_t len) const -{ - size_t left = 0, right = 0; - - if (len <= length()) - return *this; - - // From here: Length-length() >= 1 - - switch (mode) - { - case PS_TRIM_LEFT: - left = len - length(); - break; - - case PS_TRIM_RIGHT: - right = len - length(); - break; - - case PS_TRIM_BOTH: - left = (len - length() + 1) / 2; - right = (len - length() - 1) / 2; // cannot be negative - break; - - default: - debug_warn(L"CStr::Trim: invalid Mode"); - } - - return StrBase(left, ' ') + *this + StrBase(right, ' '); -} - size_t CStr::GetHashCode() const { return (size_t)fnv_hash(data(), length()*sizeof(value_type)); diff --git a/source/ps/CStr.h b/source/ps/CStr.h index 5de107a287..ab98f9cdcc 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -24,7 +24,7 @@ #define INCLUDED_CSTR /** - * Whitespace trim identifier for Trim and Pad functions + * Whitespace trim identifier for Trim functions **/ enum PS_TRIM_MODE { @@ -233,15 +233,6 @@ public: **/ CStr Trim(PS_TRIM_MODE mode) const; - /** - * Return a space padded copy of the CStr. - * - * @param PS_TRIM_MODE Mode value from trim mode enumeration. - * @param size_t Length number of pad spaces to add - * @return CStr copy of padded CStr. - **/ - CStr Pad(PS_TRIM_MODE mode, size_t len) const; - // Conversion to u16string std::u16string utf16() const { return std::u16string(begin(), end()); } diff --git a/source/ps/ProfileViewer.cpp b/source/ps/ProfileViewer.cpp index ae9c2daffe..c1251ce249 100644 --- a/source/ps/ProfileViewer.cpp +++ b/source/ps/ProfileViewer.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -405,8 +406,8 @@ namespace for (size_t r = 0; r < data.size()/cols; ++r) { for (size_t c = 0; c < cols; ++c) - m_OutputStream << (c ? " | " : "\n") - << data[r*cols + c].Pad(PS_TRIM_RIGHT, columnWidths[c]); + fmt::print(m_OutputStream, "{}{:<{}}", c ? " | " : "\n", data[r * cols + c], + columnWidths[c]); // Add dividers under some rows. (Currently only the first, since // that contains the column headers.)