From 3fa6c844dabfcbdee947eb558f526c889965b444 Mon Sep 17 00:00:00 2001 From: Adrian Szyndela Date: Fri, 11 Dec 2020 09:06:08 +0100 Subject: [PATCH] refactoring: move getter out of loop and lambda Change-Id: Iab7e249849a2ae3f61642b4ead9a973071287401 --- src/internal/storage_backend_serialized.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/storage_backend_serialized.cpp b/src/internal/storage_backend_serialized.cpp index 5509e55..e19fe43 100644 --- a/src/internal/storage_backend_serialized.cpp +++ b/src/internal/storage_backend_serialized.cpp @@ -186,17 +186,17 @@ inline ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItem(co return getDecisionItem(item, policy, ldp_serialization::ItemsType()); // make it old way for old databases auto index = impl.policyGetIndex(policy); + auto db_items = impl.policyGetItems(policy); uint32_t currentBest = 0; - auto updateCurrentBest = [¤tBest, &item, &policy, this](const auto &vec) { + auto updateCurrentBest = [¤tBest, &item, &db_items, this](const auto &vec) { // look from the back, the rule is the same as for the full database // we now only check among less elements, because the database is indexed to small lists // item_scores are in increasing order in the index, and they serve also as ids of the policy rules for (auto item_score_it = impl.containerGetReverseIterator(vec); item_score_it != impl.containerGetReverseIteratorEnd(vec); item_score_it++) { - auto db_items = impl.policyGetItems(policy); auto db_item = impl.containerLookupByIndex(db_items, *item_score_it - 1); // rules are indexed/scored from 1 if (*item_score_it > currentBest && match(item, db_item)) { currentBest = *item_score_it; -- 2.7.4