refactor repetition remover

This commit is contained in:
Akash Mozumdar 2018-11-27 16:54:19 -05:00
parent bb86bde8a5
commit 026912ca9c

View File

@ -23,16 +23,12 @@ void RemoveRepeatedChars(std::wstring& sentence)
void RemoveCyclicRepeats(std::wstring& sentence) void RemoveCyclicRepeats(std::wstring& sentence)
{ {
remove: remove:
std::wstring junk = sentence; for (std::wstring junk = sentence; junk.size() > 4; junk.pop_back())
while (junk.size() > 4)
{
junk.pop_back();
if (sentence.rfind(junk) > 0) if (sentence.rfind(junk) > 0)
{ {
sentence.erase(0, junk.size()); sentence.erase(0, junk.size());
goto remove; goto remove;
} }
}
} }
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)