MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / CodesFeedString

Function CodesFeedString

Telegram/SourceFiles/settings/settings_codes.cpp:292–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290} // namespace
291
292void CodesFeedString(SessionController *window, const QString &text) {
293 static const auto codes = GenerateCodes();
294 static auto secret = QString();
295
296 secret += text.toLower();
297 int size = secret.size(), from = 0;
298 while (size > from) {
299 auto piece = base::StringViewMid(secret,from);
300 auto found = false;
301 for (const auto &[key, method] : codes) {
302 if (piece == key) {
303 method(window);
304 from = size;
305 found = true;
306 break;
307 }
308 }
309 if (found) break;
310
311 found = ranges::any_of(codes, [&](const auto &pair) {
312 return pair.first.startsWith(piece);
313 });
314 if (found) break;
315
316 ++from;
317 }
318 secret = (size > from) ? secret.mid(from) : QString();
319}
320
321} // namespace Settings

Callers 2

keyPressEventMethod · 0.85
keyPressEventMethod · 0.85

Calls 3

GenerateCodesFunction · 0.85
QStringClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected