From e50d4e4aa5c77058b51a2f599cca6f391b6040da Mon Sep 17 00:00:00 2001 From: Patrick Venture Date: Tue, 23 Oct 2018 09:50:27 -0700 Subject: 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 --- manager.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'manager.cpp') 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 #include #include #include @@ -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) -- cgit v1.2.3