From: Matthieu Gallien Date: Fri, 29 Apr 2022 10:29:45 +0000 (+0200) Subject: improve readability of computation of currentDelay recoonect time X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~153^2^2~47^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a6571e2d8a02d93e817465fcd44d0acb642569a8;p=nextcloud-desktop.git improve readability of computation of currentDelay recoonect time Signed-off-by: Matthieu Gallien --- diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index c86efc11a..8b342427d 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -525,10 +525,11 @@ void AccountState::slotOcsError(int statusCode, const QString &message) void AccountState::slotCheckConnection() { if (_lastCheckConnectionTimer.isValid()) { - const auto currentDelay = (retryCount() <= 1 ? ConnectionValidator::DefaultCallingIntervalMsec : - (retryCount() == 2 ? ConnectionValidator::DefaultCallingIntervalMsec * 2 : - (retryCount() == 3 ? ConnectionValidator::DefaultCallingIntervalMsec * 4 : - ConnectionValidator::DefaultCallingIntervalMsec * 8))); + static constexpr auto DefaultCallingIntervalMaxMsec = static_cast(ConnectionValidator::DefaultCallingIntervalMsec) * 8; + + const auto minDelay = std::max(retryCount() * ConnectionValidator::DefaultCallingIntervalMsec, + static_cast(ConnectionValidator::DefaultCallingIntervalMsec)); + const auto currentDelay = std::min(minDelay, DefaultCallingIntervalMaxMsec); if (!_lastCheckConnectionTimer.hasExpired(currentDelay - 1)) { qCInfo(lcAccountState()) << "timer has not expired: do not check now" << _lastCheckConnectionTimer.elapsed() << currentDelay;