Skip to content

Commit

Permalink
Merge pull request #31630 from ianna/dd4hep-filtered-view-performance-v1
Browse files Browse the repository at this point in the history
[DD4hep] Filtered View Performance Step 1
  • Loading branch information
cmsbuild authored Oct 2, 2020
2 parents 396662c + 4b2ea25 commit ba6e860
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -947,14 +947,12 @@ void Converter<PartSelector>::operator()(xml_h element) const {
"+++ PartSelector for %s path: %s",
specParName.c_str(),
path.c_str());
auto npos = path.find(':');
if (npos != path.npos) {
std::string anyns{"//.*"};
if (path.substr(0, npos) == anyns) {
path = string("//").append(path.substr(npos + 1));
}

size_t pos = std::string::npos;
if ((pos = path.find("//.*:")) != std::string::npos) {
path.erase(pos + 2, 3);
}
registry.specpars[specParName].paths.emplace_back(path);
registry.specpars[specParName].paths.emplace_back(std::move(path));
}

/// Converter for <Parameter/> tags
Expand Down
19 changes: 11 additions & 8 deletions DetectorDescription/DDCMS/src/DDFilteredView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,23 +479,26 @@ std::string_view DDFilteredView::get<string_view>(const string& key) const {
int level = it_.back().GetLevel();
for (auto const& i : refs) {
auto k = find_if(begin(i->paths), end(i->paths), [&](auto const& j) {
auto const& names = split(j, "/");
int count = names.size();
auto topos = j.size();
auto frompos = j.rfind('/');
bool flag = false;
for (int nit = level; count > 0 and nit > 0; --nit) {
for (int nit = level; frompos - 1 <= topos and nit > 0; --nit) {
std::string_view name = it_.back().GetNode(nit)->GetVolume()->GetName();
auto refname = names[--count];
auto rpos = refname.find(":");
std::string_view refname{&j[frompos + 1], topos - frompos - 1};
topos = frompos;
frompos = j.substr(0, topos).rfind('/');

auto rpos = refname.find(':');
if (rpos == refname.npos) {
name = noNamespace(name);
} else {
if (name.find(":") == name.npos) {
if (name.find(':') == name.npos) {
refname.remove_prefix(rpos + 1);
}
}
auto cpos = refname.find("[");
auto cpos = refname.rfind('[');
if (cpos != refname.npos) {
if (std::stoi(std::string(refname.substr(cpos + 1, refname.find("]")))) == copyNum()) {
if (std::stoi(std::string(refname.substr(cpos + 1, refname.rfind(']')))) == copyNum()) {
refname.remove_suffix(refname.size() - cpos);
flag = true;
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void testDDFilteredViewGoTo::checkFilteredView() {
if (count == 45) {
testPos = fview.navPos();
}
if (count == 1000) {
if (count == 50) {
break;
}
count++;
Expand Down

0 comments on commit ba6e860

Please sign in to comment.