From bd6f327d4fec44ee115a7e1d583c3cedd9d54980 Mon Sep 17 00:00:00 2001 From: Ianna Osborne <ianna.osborne@cern.ch> Date: Tue, 13 Oct 2020 15:32:35 +0200 Subject: [PATCH] replace tbb with std containers --- DDCore/include/DD4hep/Filter.h | 30 +++++-------------------- DDCore/include/DD4hep/SpecParRegistry.h | 19 ++++++++-------- DDCore/src/Filter.cpp | 4 ++++ DDCore/src/SpecParRegistry.cpp | 3 +-- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/DDCore/include/DD4hep/Filter.h b/DDCore/include/DD4hep/Filter.h index dcc050547..734d48b44 100644 --- a/DDCore/include/DD4hep/Filter.h +++ b/DDCore/include/DD4hep/Filter.h @@ -29,39 +29,18 @@ // Created: Tue, 12 Mar 2019 09:51:33 CET // // - #include <memory> #include <vector> #include <regex> +#include <unordered_map> namespace dd4hep { struct SpecPar; struct Filter { - void print() const { - /* edm::LogVerbatim("Geometry").log([&](auto& log) { */ - /* for (const auto& it : skeys) { */ - /* log << it << ", "; */ - /* } */ - /* if (next) { */ - /* log << "Next:\n"; */ - /* print(next); */ - /* } */ - /* if (up) { */ - /* log << "Up:\n"; */ - /* up->print(); */ - /* } */ - /* }); */ - } - - // void print(const std::unique_ptr<Filter>& filter) const { - /* edm::LogVerbatim("Geometry").log([&](auto& log) { */ - /* for (const auto& it : filter->skeys) { */ - /* log << it << ", "; */ - /* } */ - /* }); */ - //} - + std::vector<bool> isRegex; + std::vector<bool> hasNamaspace; + std::vector<int> index; std::vector<std::string_view> skeys; std::vector<std::regex> keys; std::unique_ptr<Filter> next; @@ -72,6 +51,7 @@ namespace dd4hep { namespace dd { bool accepted(std::vector<std::regex> const&, std::string_view); bool isRegex(std::string_view); + bool hasNamespace(std::string_view); bool isMatch(std::string_view, std::string_view); bool compareEqual(std::string_view, std::string_view); bool compareEqual(std::string_view, std::regex); diff --git a/DDCore/include/DD4hep/SpecParRegistry.h b/DDCore/include/DD4hep/SpecParRegistry.h index 4ef33a2a9..ae80b3df4 100644 --- a/DDCore/include/DD4hep/SpecParRegistry.h +++ b/DDCore/include/DD4hep/SpecParRegistry.h @@ -15,18 +15,18 @@ #include <string> #include <string_view> -#include "tbb/concurrent_unordered_map.h" -#include "tbb/concurrent_vector.h" +#include <unordered_map> +#include <vector> namespace dd4hep { - using Paths = tbb::concurrent_vector<std::string>; - using PartSelectionMap = tbb::concurrent_unordered_map<std::string, tbb::concurrent_vector<std::string>>; - using VectorsMap = tbb::concurrent_unordered_map<std::string, tbb::concurrent_vector<double>>; + using Paths = std::vector<std::string>; + using PartSelectionMap = std::unordered_map<std::string, std::vector<std::string>>; + using VectorsMap = std::unordered_map<std::string, std::vector<double>>; struct SpecPar { std::string_view strValue(const std::string&) const; - bool hasValue(const std::string& key) const; - bool hasPath(const std::string& path) const; + bool hasValue(const std::string&) const; + bool hasPath(const std::string&) const; double dblValue(const std::string&) const; template <typename T> @@ -35,11 +35,10 @@ namespace dd4hep { Paths paths; PartSelectionMap spars; VectorsMap numpars; - std::string_view name; }; - using SpecParMap = tbb::concurrent_unordered_map<std::string, SpecPar>; - using SpecParRefs = std::vector<const SpecPar*>; + using SpecParMap = std::unordered_map<std::string, SpecPar>; + using SpecParRefs = std::vector<std::pair<std::string_view, const SpecPar*>>; struct SpecParRegistry { void filter(SpecParRefs&, const std::string&, const std::string& = "") const; diff --git a/DDCore/src/Filter.cpp b/DDCore/src/Filter.cpp index 74a09e832..fa8e66be9 100644 --- a/DDCore/src/Filter.cpp +++ b/DDCore/src/Filter.cpp @@ -32,6 +32,10 @@ namespace dd4hep { return (input.find(".") != std::string_view::npos) || (input.find("*") != std::string_view::npos); } + bool hasNamespace(std::string_view input) { + return (input.find(":") != std::string_view::npos); + } + string_view realTopName(string_view input) { string_view v = input; auto first = v.find_first_of("//"); diff --git a/DDCore/src/SpecParRegistry.cpp b/DDCore/src/SpecParRegistry.cpp index e7366d251..db6dcd7d5 100644 --- a/DDCore/src/SpecParRegistry.cpp +++ b/DDCore/src/SpecParRegistry.cpp @@ -110,8 +110,7 @@ void SpecParRegistry::filter(SpecParRefs& refs, const std::string& attribute, co } }); if (found) { - k.second.name = k.first; - refs.emplace_back(&k.second); + refs.emplace_back(std::make_pair(k.first, &k.second)); } }); } -- GitLab