summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index ba5f575b..05b6982c 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -111,14 +111,13 @@ std::string &replaceCharacters(std::string &str,
return str;
}
-std::string removeColors(std::string msg)
+std::string &removeColors(std::string &msg)
{
- for (unsigned int f = 0; f < msg.length() - 2 && msg.length() > 2; f++)
+ auto pos = msg.find("##");
+ while (pos != std::string::npos && msg.length() - pos >= 3)
{
- while (msg.length() > f + 2 && msg.at(f) == '#' && msg.at(f + 1) == '#')
- {
- msg = msg.erase(f, 3);
- }
+ msg.erase(pos, 3);
+ pos = msg.find("##", pos);
}
return msg;
}