From d0ce55be6f2d4c301d04fe6563d9202080887b77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 20 Nov 2019 21:00:12 +0900 Subject: [PATCH] [neurun] Refine BackendManager ctor (#9058) - Use `split` helper function rather than directly parsing - Use container's `empty()` method rather than checking size is 0 Signed-off-by: Hanjoung Lee --- runtime/neurun/core/src/backend/BackendManager.cc | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/runtime/neurun/core/src/backend/BackendManager.cc b/runtime/neurun/core/src/backend/BackendManager.cc index 001944f..6cc1deb 100644 --- a/runtime/neurun/core/src/backend/BackendManager.cc +++ b/runtime/neurun/core/src/backend/BackendManager.cc @@ -22,6 +22,7 @@ #include "backend/IConfig.h" #include "util/logging.h" #include "util/ConfigSource.h" +#include "misc/string_helpers.h" namespace neurun { @@ -102,22 +103,13 @@ void BackendManager::loadBackend(const std::string &backend) BackendManager::BackendManager() { const auto backends = util::getConfigString(util::config::BACKENDS); - size_t prev_pos = 0; - auto pos = backends.find(";"); - while (pos != std::string::npos) + for (auto &backend_id : nnfw::misc::split(backends, ';')) { - loadBackend(backends.substr(prev_pos, pos - prev_pos)); - prev_pos = pos + 1; - pos = backends.find(";", prev_pos); - } - // if backends doesn't terminate with ";" - if (prev_pos < backends.size()) - { - loadBackend(backends.substr(prev_pos)); + loadBackend(backend_id); } // No loaded backend - if (_available_backends.size() == 0) + if (_available_backends.empty()) { VERBOSE(BackendManager::loadBackend) << "There is no loaded backend\n"; abort(); -- 2.7.4