From 026912ca9ce9388acbec23ccb588e47e43a8877c Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Tue, 27 Nov 2018 16:54:19 -0500 Subject: [PATCH] refactor repetition remover --- extensions/removerepeat/removerepeat.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/extensions/removerepeat/removerepeat.cpp b/extensions/removerepeat/removerepeat.cpp index 61742c7..9065efb 100644 --- a/extensions/removerepeat/removerepeat.cpp +++ b/extensions/removerepeat/removerepeat.cpp @@ -23,16 +23,12 @@ void RemoveRepeatedChars(std::wstring& sentence) void RemoveCyclicRepeats(std::wstring& sentence) { remove: - std::wstring junk = sentence; - while (junk.size() > 4) - { - junk.pop_back(); + for (std::wstring junk = sentence; junk.size() > 4; junk.pop_back()) if (sentence.rfind(junk) > 0) { sentence.erase(0, junk.size()); goto remove; } - } } bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)