mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-11 00:34:27 +00:00
Cleanup: remove unneeded checks on remaining buffer size
This commit is contained in:
parent
affceea0ae
commit
edb21620ea
@ -475,8 +475,8 @@ static void FormatGenericCurrency(StringBuilder &builder, const CurrencySpec *sp
|
||||
|
||||
/* convert from negative */
|
||||
if (number < 0) {
|
||||
if (!builder.Utf8Encode(SCC_PUSH_COLOUR)) return;
|
||||
if (!builder.Utf8Encode(SCC_RED)) return;
|
||||
builder.Utf8Encode(SCC_PUSH_COLOUR);
|
||||
builder.Utf8Encode(SCC_RED);
|
||||
builder += '-';
|
||||
number = -number;
|
||||
}
|
||||
@ -1225,8 +1225,6 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
|
||||
for (const auto &cs : _sorted_cargo_specs) {
|
||||
if (!HasBit(cmask, cs->Index())) continue;
|
||||
|
||||
if (builder.Remaining() < 2) break; // ", "
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
|
@ -15,9 +15,6 @@
|
||||
/**
|
||||
* Equivalent to the std::back_insert_iterator in function, with some
|
||||
* convenience helpers for string concatenation.
|
||||
*
|
||||
* The formatter is currently backed by an external char buffer, and has some
|
||||
* extra functions to ease the migration from char buffers to std::string.
|
||||
*/
|
||||
class StringBuilder {
|
||||
std::string *string;
|
||||
@ -80,11 +77,10 @@ public:
|
||||
* Encode the given Utf8 character into the output buffer.
|
||||
* @param c The character to encode.
|
||||
*/
|
||||
bool Utf8Encode(WChar c)
|
||||
void Utf8Encode(WChar c)
|
||||
{
|
||||
auto iterator = std::back_inserter(*this->string);
|
||||
::Utf8Encode(iterator, c);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,15 +93,6 @@ public:
|
||||
this->string->erase(this->string->size() - std::min(amount, this->string->size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remaining number of characters that can be placed.
|
||||
* @return The number of characters.
|
||||
*/
|
||||
ptrdiff_t Remaining()
|
||||
{
|
||||
return 42; // Just something big-ish, as there's always space (until allocation fails)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current index in the string.
|
||||
* @return The index.
|
||||
|
Loading…
Reference in New Issue
Block a user