Improve getDecisionItem() and match() performance 06/200906/5
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 5 Mar 2019 14:48:45 +0000 (15:48 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 7 Mar 2019 14:22:41 +0000 (15:22 +0100)
Change-Id: I117a1d496cb709fc63958e0d826725fb01597daa

src/internal/policy_containers.hpp
src/internal/storage_backend_serialized.cpp

index 5b0ddca..47f70f0 100644 (file)
@@ -45,7 +45,7 @@ template <typename TI>
 class PolicySRBase : public PolicyBase<TI> {
 public:
        DecisionItem getDecisionItem(const typename TI::match_type &item) const {
-               for (auto i : *this) {
+               for (auto &i : *this) {
                        tslog::log_verbose("-read: ", i.getDecision(), " ", i, "\n");
 
                        if (item.match(i.getType(), i.getInterface(), i.getPath(),
index fb5ccda..ae2b350 100644 (file)
@@ -162,10 +162,18 @@ void StorageBackendSerialized::printContent() const {
        pimpl->printContent();
 }
 
+inline boost::string_ref s(const flatbuffers::String *str) {
+       return boost::string_ref(str->c_str(), str->size());
+}
+
 template <typename T, typename I>
 bool match(const T &match, const I *i) {
-       return match.match(makeMessageType(i->type()), i->interface()->c_str(), i->path()->c_str(),
-                       i->member()->c_str(), i->name()->c_str(), i->is_name_prefix());
+       return match.match(makeMessageType(i->type()),
+                                          s(i->interface()),
+                                          s(i->path()),
+                                          s(i->member()),
+                                          s(i->name()),
+                                          i->is_name_prefix());
 }
 
 template <> bool match(const ldp_xml_parser::MatchItemAccess &match, const FB::ItemAccess *item) {