mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 05:38:06 -06:00
Use const accessor
This avoids an unnecessary check to the container internal atomic variable and prevents potential detachment. PR #22280.
This commit is contained in:
@@ -103,8 +103,8 @@ void AuthController::logoutAction() const
|
||||
|
||||
bool AuthController::isBanned() const
|
||||
{
|
||||
const auto failedLoginIter = m_clientFailedLogins.find(m_sessionManager->clientId());
|
||||
if (failedLoginIter == m_clientFailedLogins.end())
|
||||
const auto failedLoginIter = m_clientFailedLogins.constFind(m_sessionManager->clientId());
|
||||
if (failedLoginIter == m_clientFailedLogins.cend())
|
||||
return false;
|
||||
|
||||
bool isBanned = (failedLoginIter->banTimer.remainingTime() >= 0);
|
||||
|
||||
@@ -131,8 +131,8 @@ void SearchController::stopAction()
|
||||
|
||||
const int id = params()[u"id"_s].toInt();
|
||||
|
||||
const auto iter = m_searchHandlers.find(id);
|
||||
if (iter == m_searchHandlers.end())
|
||||
const auto iter = m_searchHandlers.constFind(id);
|
||||
if (iter == m_searchHandlers.cend())
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
|
||||
@@ -176,8 +176,8 @@ void SearchController::resultsAction()
|
||||
int limit = params()[u"limit"_s].toInt();
|
||||
int offset = params()[u"offset"_s].toInt();
|
||||
|
||||
const auto iter = m_searchHandlers.find(id);
|
||||
if (iter == m_searchHandlers.end())
|
||||
const auto iter = m_searchHandlers.constFind(id);
|
||||
if (iter == m_searchHandlers.cend())
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
|
||||
@@ -207,8 +207,8 @@ void SearchController::deleteAction()
|
||||
|
||||
const int id = params()[u"id"_s].toInt();
|
||||
|
||||
const auto iter = m_searchHandlers.find(id);
|
||||
if (iter == m_searchHandlers.end())
|
||||
const auto iter = m_searchHandlers.constFind(id);
|
||||
if (iter == m_searchHandlers.cend())
|
||||
throw APIError(APIErrorType::NotFound);
|
||||
|
||||
const std::shared_ptr<SearchHandler> &searchHandler = iter.value();
|
||||
|
||||
@@ -864,7 +864,7 @@ void SyncController::onTorrentAboutToBeRemoved(BitTorrent::Torrent *torrent)
|
||||
|
||||
for (const BitTorrent::TrackerEntryStatus &status : asConst(torrent->trackers()))
|
||||
{
|
||||
auto iter = m_knownTrackers.find(status.url);
|
||||
const auto iter = m_knownTrackers.find(status.url);
|
||||
Q_ASSERT(iter != m_knownTrackers.end());
|
||||
if (iter == m_knownTrackers.end()) [[unlikely]]
|
||||
continue;
|
||||
|
||||
@@ -339,8 +339,8 @@ void WebApplication::doProcessRequest()
|
||||
}
|
||||
|
||||
// Filter HTTP methods
|
||||
const auto allowedMethodIter = m_allowedMethod.find({scope, action});
|
||||
if (allowedMethodIter == m_allowedMethod.end())
|
||||
const auto allowedMethodIter = m_allowedMethod.constFind({scope, action});
|
||||
if (allowedMethodIter == m_allowedMethod.cend())
|
||||
{
|
||||
// by default allow both GET, POST methods
|
||||
if ((m_request.method != Http::METHOD_GET) && (m_request.method != Http::METHOD_POST))
|
||||
|
||||
Reference in New Issue
Block a user