diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-07-06 02:47:51 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-07-07 15:17:28 +0200 |
commit | ce115e4f438b72abeb6a2af7b21331fb2b15842a (patch) | |
tree | 5e59bc7bce9a218a6afbce3f0b39903a99fd5a2d | |
parent | 48c2bc4d8006d3e3eb2c20dfc7a00f78eb82bcda (diff) |
m_stripcolor Removing a character from a string while iterating it is slightly less complicated
-rw-r--r-- | src/modules/m_stripcolor.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
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; } |