Skip to content

Commit e7f919b

Browse files
committed
Hold ProductResolverIndexHelper via const
To set the helper, a temporary is created and filled and then moved to the ProductRegistry.
1 parent 862b9fd commit e7f919b

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

DataFormats/Provenance/interface/ProductRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ namespace edm {
152152
std::array<bool, NumBranchTypes> productProduced_;
153153
bool anyProductProduced_;
154154

155-
std::array<edm::propagate_const<std::shared_ptr<ProductResolverIndexHelper>>, NumBranchTypes> productLookups_;
155+
std::array<std::shared_ptr<const ProductResolverIndexHelper>, NumBranchTypes> productLookups_;
156156

157157
std::array<ProductResolverIndex, NumBranchTypes> nextIndexValues_;
158158

DataFormats/Provenance/src/ProductRegistry.cc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ namespace edm {
143143
}
144144

145145
std::shared_ptr<ProductResolverIndexHelper const> ProductRegistry::productLookup(BranchType branchType) const {
146-
return get_underlying_safe(transient_.productLookups_[branchType]);
147-
}
148-
149-
std::shared_ptr<ProductResolverIndexHelper> ProductRegistry::productLookup(BranchType branchType) {
150-
return get_underlying_safe(transient_.productLookups_[branchType]);
146+
return transient_.productLookups_[branchType];
151147
}
152148

153149
void ProductRegistry::setFrozen(bool initializeLookupInfo) {
@@ -319,6 +315,11 @@ namespace edm {
319315

320316
transient_.branchIDToIndex_.clear();
321317

318+
std::array<std::shared_ptr<ProductResolverIndexHelper>, NumBranchTypes> new_productLookups{
319+
{std::make_shared<ProductResolverIndexHelper>(),
320+
std::make_shared<ProductResolverIndexHelper>(),
321+
std::make_shared<ProductResolverIndexHelper>(),
322+
std::make_shared<ProductResolverIndexHelper>()}};
322323
for (auto const& product : productList_) {
323324
auto const& desc = product.second;
324325

@@ -438,8 +439,7 @@ namespace edm {
438439
}
439440
}
440441
}
441-
ProductResolverIndex index = productLookup(desc.branchType())
442-
->insert(typeID,
442+
ProductResolverIndex index = new_productLookups[desc.branchType()]->insert(typeID,
443443
desc.moduleLabel().c_str(),
444444
desc.productInstanceName().c_str(),
445445
desc.processName().c_str(),
@@ -454,9 +454,12 @@ namespace edm {
454454
throwMissingDictionariesException(missingDictionaries, context, producedTypes, branchNamesForMissing);
455455
}
456456

457-
for (auto& iterProductLookup : transient_.productLookups_) {
457+
for (auto& iterProductLookup : new_productLookups) {
458458
iterProductLookup->setFrozen();
459459
}
460+
for (size_t i = 0; i < new_productLookups.size(); ++i) {
461+
transient_.productLookups_[i] = std::move(new_productLookups[i]);
462+
}
460463

461464
unsigned int indexIntoNextIndexValue = 0;
462465
for (auto const& iterProductLookup : transient_.productLookups_) {

0 commit comments

Comments
 (0)