2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

Instantiate QRegularExpression instances statically

This commit is contained in:
Ilya Fedin
2023-12-22 03:50:04 +04:00
committed by John Preston
parent 4b297bfa09
commit e6b9a07163
18 changed files with 74 additions and 47 deletions

View File

@@ -1354,8 +1354,11 @@ bool Instance::Private::onErrorDefault(
const auto &type = error.type();
const auto code = error.code();
auto badGuestDc = (code == 400) && (type == u"FILE_ID_INVALID"_q);
static const auto MigrateRegExp = QRegularExpression("^(FILE|PHONE|NETWORK|USER)_MIGRATE_(\\d+)$");
static const auto FloodWaitRegExp = QRegularExpression("^FLOOD_WAIT_(\\d+)$");
static const auto SlowmodeWaitRegExp = QRegularExpression("^SLOWMODE_WAIT_(\\d+)$");
QRegularExpressionMatch m1, m2;
if ((m1 = QRegularExpression("^(FILE|PHONE|NETWORK|USER)_MIGRATE_(\\d+)$").match(type)).hasMatch()) {
if ((m1 = MigrateRegExp.match(type)).hasMatch()) {
if (!requestId) return false;
auto dcWithShift = ShiftedDcId(0);
@@ -1458,8 +1461,8 @@ bool Instance::Private::onErrorDefault(
return true;
} else if (code < 0
|| code >= 500
|| (m1 = QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(type)).hasMatch()
|| ((m2 = QRegularExpression("^SLOWMODE_WAIT_(\\d+)$").match(type)).hasMatch()
|| (m1 = FloodWaitRegExp.match(type)).hasMatch()
|| ((m2 = SlowmodeWaitRegExp.match(type)).hasMatch()
&& m2.captured(1).toInt() < 3)) {
if (!requestId) return false;