perf optimization

This commit is contained in:
Akash Mozumdar 2019-02-06 19:48:42 -05:00
parent ac86323010
commit 5e53e63e07

View File

@ -41,13 +41,16 @@ void TextThread::Push(const BYTE* data, int len)
else Host::AddConsoleOutput(INVALID_CODEPAGE); else Host::AddConsoleOutput(INVALID_CODEPAGE);
lastPushTime = GetTickCount(); lastPushTime = GetTickCount();
if (std::all_of(buffer.begin(), buffer.end(), [&](wchar_t c) { return repeatingChars.count(c) > 0; })) buffer.clear(); if (filterRepetition)
if (filterRepetition && Util::RemoveRepetition(buffer)) // sentence repetition detected, which means the entire sentence has already been received {
if (std::all_of(buffer.begin(), buffer.end(), [&](auto ch) { return repeatingChars.find(ch) != repeatingChars.end(); })) buffer.clear();
if (Util::RemoveRepetition(buffer)) // sentence repetition detected, which means the entire sentence has already been received
{ {
repeatingChars = std::unordered_set(buffer.begin(), buffer.end()); repeatingChars = std::unordered_set(buffer.begin(), buffer.end());
AddSentence(buffer); AddSentence(buffer);
buffer.clear(); buffer.clear();
} }
}
} }
void TextThread::Flush() void TextThread::Flush()