From c72263a4ce72a4fc4344fd6da536e00beb2b138a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <rafael.carre@savoirfairelinux.com> Date: Mon, 15 Aug 2011 15:55:14 -0400 Subject: [PATCH] account map : simplify --- daemon/src/managerimpl.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 6950dce94b..7c91a35257 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -4028,42 +4028,27 @@ void ManagerImpl::unloadAccountMap () { _debug ("Manager: Unload account map"); - AccountMap::iterator iter = _accountMap.begin(); - - while (iter != _accountMap.end()) { + AccountMap::iterator iter; + for (iter = _accountMap.begin(); iter != _accountMap.end(); ++iter) { // Avoid removing the IP2IP account twice - if (iter->first != "") { + if (iter->first != "") delete iter->second; - iter->second = NULL; - } - - iter++; } _accountMap.clear(); - - } bool ManagerImpl::accountExists (const std::string& accountID) { - AccountMap::iterator iter = _accountMap.find (accountID); - - if (iter == _accountMap.end()) { - return false; - } - - return true; + return _accountMap.find (accountID) != _accountMap.end(); } Account* ManagerImpl::getAccount (const std::string& accountID) { - AccountMap::iterator iter = _accountMap.find (accountID); - - if (iter != _accountMap.end()) { - return iter->second; - } + Account *a = _accountMap[accountID]; + if (a) + return a; _debug ("Manager: Did not found account %s, returning IP2IP account", accountID.c_str()); return _directIpAccount; -- GitLab