diff options
author | Kun Yi <kunyi731@gmail.com> | 2019-11-22 20:01:28 -0800 |
---|---|---|
committer | Kun Yi <kunyi731@gmail.com> | 2019-11-25 10:18:55 -0800 |
commit | beee9e54ae3e20bce5e466773cfda9232382e2e7 (patch) | |
tree | 92a24e6ea40fc67d0ea70fe59032022fa5b0e971 | |
parent | cd833aa11075ac1041531270060e1fb3ba8aa5ac (diff) | |
download | phosphor-ipmi-blobs-beee9e54ae3e20bce5e466773cfda9232382e2e7.tar.gz phosphor-ipmi-blobs-beee9e54ae3e20bce5e466773cfda9232382e2e7.zip |
cleanup: remove getPath
The getPath call is only used once. Getting rid of it makes it easier to
understand.
Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: Ifc8859f5fc68bb594003a6db7f7e80b1c1dfed28
-rw-r--r-- | manager.cpp | 32 | ||||
-rw-r--r-- | manager.hpp | 8 |
2 files changed, 13 insertions, 27 deletions
diff --git a/manager.cpp b/manager.cpp index 870bf60..64cc08f 100644 --- a/manager.cpp +++ b/manager.cpp @@ -27,17 +27,21 @@ namespace blobs void BlobManager::eraseSession(GenericBlobInterface* handler, uint16_t session) { - /* Ok for openSessions[handler] to be an empty set */ - openSessions[handler].erase(session); - - auto path = getPath(session); - openFiles[path]--; - if (openFiles[path] == 0) + if (auto item = sessions.find(session); item != sessions.end()) { - openFiles.erase(path); + const auto& blobId = item->second.blobId; + + /* Ok for openSessions[handler] to be an empty set */ + openSessions[handler].erase(session); + openFiles[blobId]--; + if (openFiles[blobId] == 0) + { + openFiles.erase(blobId); + } + + /* Erase at the end after using the session info */ + sessions.erase(session); } - /* Cannot erase before getPath() is called */ - sessions.erase(session); } void BlobManager::cleanUpStaleSessions(GenericBlobInterface* handler) @@ -183,16 +187,6 @@ GenericBlobInterface* BlobManager::getActionHandle(uint16_t session, return nullptr; } -std::string BlobManager::getPath(uint16_t session) const -{ - if (auto item = sessions.find(session); item != sessions.end()) - { - return item->second.blobId; - } - - return ""; -} - bool BlobManager::stat(const std::string& path, BlobMeta* meta) { /* meta should never be NULL. */ diff --git a/manager.hpp b/manager.hpp index 3097201..a7e9936 100644 --- a/manager.hpp +++ b/manager.hpp @@ -258,14 +258,6 @@ class BlobManager : public ManagerInterface uint16_t session, uint16_t requiredFlags = std::numeric_limits<uint16_t>::max()); - /** - * Given a session id will return associated path. - * - * @param[in] session - the session. - * @return the path or "" on failure. - */ - std::string getPath(uint16_t session) const; - private: /* Helper method to erase a session from all maps */ void eraseSession(GenericBlobInterface* handler, uint16_t session); |