diff options
author | Patrick Venture <venture@google.com> | 2018-10-23 09:50:27 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2018-10-24 19:17:44 +0000 |
commit | e50d4e4aa5c77058b51a2f599cca6f391b6040da (patch) | |
tree | 0d13e2c0ebc173adacd92d78bcaabb4e938fbe3e | |
parent | a6e21a0700fb32211f5ed00c605463e69becc9a8 (diff) | |
download | phosphor-ipmi-blobs-e50d4e4aa5c77058b51a2f599cca6f391b6040da.tar.gz phosphor-ipmi-blobs-e50d4e4aa5c77058b51a2f599cca6f391b6040da.zip |
manager: fixup to use find_if
[manager.cpp:150]: (style) Consider using std::find_if algorithm
instead of a raw loop.
Note: Amusingly switching to a const iterator allowed cppcheck to find
this cleanup.
Change-Id: I16d87d4dde165fbb226259d1abc8deaa51569af1
Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r-- | manager.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/manager.cpp b/manager.cpp index 0a30625..adabe84 100644 --- a/manager.cpp +++ b/manager.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include <algorithm> #include <blobs-ipmid/manager.hpp> #include <memory> #include <string> @@ -142,18 +143,15 @@ bool BlobManager::open(uint16_t flags, const std::string& path, GenericBlobInterface* BlobManager::getHandler(const std::string& path) { /* Find a handler. */ - GenericBlobInterface* handler = nullptr; - - for (const auto& h : handlers) + auto h = std::find_if( + handlers.begin(), handlers.end(), + [&path](const auto& iter) { return (iter->canHandleBlob(path)); }); + if (h != handlers.end()) { - if (h->canHandleBlob(path)) - { - handler = h.get(); - break; - } + return h->get(); } - return handler; + return nullptr; } GenericBlobInterface* BlobManager::getHandler(uint16_t session) |