Remove CStr::Pad

It was only used once. It can be replaced by fmt.
This commit is contained in:
phosit
2026-08-24 13:34:37 +02:00
parent aa86258751
commit 73d043fde5
3 changed files with 4 additions and 43 deletions
-31
View File
@@ -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));
+1 -10
View File
@@ -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()); }
+3 -2
View File
@@ -43,6 +43,7 @@
#include <SDL_keycode.h>
#include <algorithm>
#include <ctime>
#include <fmt/ostream.h>
#include <fstream>
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
@@ -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.)