From ce115e4f438b72abeb6a2af7b21331fb2b15842a Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Fri, 6 Jul 2012 02:47:51 +0200 Subject: m_stripcolor Removing a character from a string while iterating it is slightly less complicated --- src/modules/m_stripcolor.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index cd4f35c4b..86f307bae 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -72,8 +72,8 @@ class ModuleStripColor : public Module { /* refactor this completely due to SQUIT bug since the old code would strip last char and replace with \0 --peavey */ int seq = 0; - std::string::iterator i,safei; - for (i = sentence.begin(); i != sentence.end();) + + for (std::string::iterator i = sentence.begin(); i != sentence.end();) { if (*i == 3) seq = 1; @@ -89,20 +89,7 @@ class ModuleStripColor : public Module seq = 0; if (seq || ((*i == 2) || (*i == 15) || (*i == 22) || (*i == 21) || (*i == 31))) - { - if (i != sentence.begin()) - { - safei = i; - --i; - sentence.erase(safei); - ++i; - } - else - { - sentence.erase(i); - i = sentence.begin(); - } - } + i = sentence.erase(i); else ++i; } -- cgit v1.2.3