mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Reserve vectors before pushing and other code quality changes (#11161)
This commit is contained in:
parent
3e1904fa8c
commit
f0bad0e2ba
20 changed files with 106 additions and 108 deletions
|
@ -65,12 +65,14 @@ void EnrichedString::operator=(const wchar_t *str)
|
|||
addAtEnd(translate_string(std::wstring(str)), m_default_color);
|
||||
}
|
||||
|
||||
void EnrichedString::addAtEnd(const std::wstring &s, const SColor &initial_color)
|
||||
void EnrichedString::addAtEnd(const std::wstring &s, SColor initial_color)
|
||||
{
|
||||
SColor color(initial_color);
|
||||
bool use_default = (m_default_length == m_string.size() &&
|
||||
color == m_default_color);
|
||||
|
||||
m_colors.reserve(m_colors.size() + s.size());
|
||||
|
||||
size_t i = 0;
|
||||
while (i < s.length()) {
|
||||
if (s[i] != L'\x1b') {
|
||||
|
@ -200,12 +202,6 @@ const std::wstring &EnrichedString::getString() const
|
|||
return m_string;
|
||||
}
|
||||
|
||||
void EnrichedString::setDefaultColor(const irr::video::SColor &color)
|
||||
{
|
||||
m_default_color = color;
|
||||
updateDefaultColor();
|
||||
}
|
||||
|
||||
void EnrichedString::updateDefaultColor()
|
||||
{
|
||||
sanity_check(m_default_length <= m_colors.size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue