diff --git a/Control/AthAllocators/AthAllocators/DataPool.h b/Control/AthAllocators/AthAllocators/DataPool.h index bc5f2ebfba64f6a0c72e91fbf43b64d0a20329da..33a2805ced5940abf7f18cb611d7909eec086899 100644 --- a/Control/AthAllocators/AthAllocators/DataPool.h +++ b/Control/AthAllocators/AthAllocators/DataPool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef ATHALLOCATORS_DATAPOOL_H @@ -159,7 +159,7 @@ public: const static typename alloc_t::Params s_params; /// minimum number of elements in pool - static const unsigned int s_minRefCount = 1024; + static constexpr size_t s_minRefCount = 1024; }; diff --git a/Control/AthAllocators/AthAllocators/DataPool.icc b/Control/AthAllocators/AthAllocators/DataPool.icc index 890fca4a2fa275096bd579a8f7b85620b19b7db8..da78e3de571b4e8d574f250f8096c8802eb2b604 100644 --- a/Control/AthAllocators/AthAllocators/DataPool.icc +++ b/Control/AthAllocators/AthAllocators/DataPool.icc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //----------------------------------------------------------- @@ -22,7 +22,7 @@ DataPool::DataPool(size_type n /*= 0*/) : m_handle (&s_params) { if (n > 0) - m_handle.reserve (n); + m_handle.reserve (std::max (n, s_minRefCount)); } template @@ -31,7 +31,7 @@ DataPool::DataPool(const EventContext& ctx, : m_handle (static_cast(nullptr), ctx, &s_params) { if (n > 0) - m_handle.reserve (n); + m_handle.reserve (std::max (n, s_minRefCount)); } template @@ -40,7 +40,7 @@ DataPool::DataPool(SG::Arena* arena, : m_handle (arena, nullptr, &s_params) { if (n > 0) - m_handle.reserve (n); + m_handle.reserve (std::max (n, s_minRefCount)); } //----------------------------------------------------------- diff --git a/Control/AthAllocators/src/ArenaBlock.cxx b/Control/AthAllocators/src/ArenaBlock.cxx index 01bb5569a10ebd78f75f25b46b55f7105ad55e08..064b43559cdb54bf57953c9231f8fcec1b57271c 100644 --- a/Control/AthAllocators/src/ArenaBlock.cxx +++ b/Control/AthAllocators/src/ArenaBlock.cxx @@ -172,7 +172,7 @@ void ArenaBlock::protect() int stat = mprotect (this, m_size*m_elt_size+ArenaBlockBodyOffset, PROT_READ); if (stat) { - throw SG::ExcProtection (stat); + throw SG::ExcProtection (errno); } } @@ -188,7 +188,7 @@ void ArenaBlock::unprotect() int stat = mprotect (this, m_size*m_elt_size+ArenaBlockBodyOffset, PROT_READ + PROT_WRITE); if (stat) { - throw SG::ExcProtection (stat); + throw SG::ExcProtection (errno); } } diff --git a/Control/AthAllocators/src/ArenaBlockAllocatorBase.cxx b/Control/AthAllocators/src/ArenaBlockAllocatorBase.cxx index 861f857f0b9ddbfba50698afc76203f5e9604087..7521344dbc45ce4c9ba29adcee62a6b070e94dd9 100644 --- a/Control/AthAllocators/src/ArenaBlockAllocatorBase.cxx +++ b/Control/AthAllocators/src/ArenaBlockAllocatorBase.cxx @@ -124,11 +124,8 @@ void ArenaBlockAllocatorBase::reserve (size_t size) } if (size > m_stats.elts.total) { // Growing the pool. - // Make a new block of the required size (but not less than nblock). + // Make a new block of the required size. size_t sz = size - m_stats.elts.total; - if (sz < m_params.nblock) { - sz = m_params.nblock; - } ArenaBlock* newblock = ArenaBlock::newBlock (sz, m_params.eltSize, m_params.constructor); diff --git a/InnerDetector/InDetRecEvent/SiSPSeededTrackFinderData/src/SiTrajectory_xk.cxx b/InnerDetector/InDetRecEvent/SiSPSeededTrackFinderData/src/SiTrajectory_xk.cxx index 6825946d83b2b42542bf34855b1f14a643a8a84c..a3c918b6b90775f29fbe192c2b3ea415e1405ff9 100644 --- a/InnerDetector/InDetRecEvent/SiSPSeededTrackFinderData/src/SiTrajectory_xk.cxx +++ b/InnerDetector/InDetRecEvent/SiSPSeededTrackFinderData/src/SiTrajectory_xk.cxx @@ -57,6 +57,7 @@ InDet::SiTrajectory_xk::convertToTrackStateOnSurface() { auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + dtsos->reserve (1 + m_lastElement - m_firstElement); bool multi = m_tools->multiTrack(); if (m_nclusters <= m_tools->clustersmin() || pTfirst() < m_tools->pTmin()) multi = false; @@ -105,6 +106,7 @@ InDet::SiTrajectory_xk::convertToTrackStateOnSurfaceWithNewDirection() { auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + dtsos->reserve (1 + m_lastElement - m_firstElement); bool multi = m_tools->multiTrack(); if (pTfirst() < m_tools->pTmin()) multi = false; @@ -157,6 +159,7 @@ Trk::TrackStateOnSurfaceProtContainer::ContainerUniquePtr InDet::SiTrajectory_xk::convertToSimpleTrackStateOnSurface() { auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + dtsos->reserve (2 + m_lastElement - m_firstElement); int i = m_firstElement; @@ -210,6 +213,7 @@ Trk::TrackStateOnSurfaceProtContainer::ContainerUniquePtr InDet::SiTrajectory_xk::convertToSimpleTrackStateOnSurfaceWithNewDirection() { auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + dtsos->reserve (1 + m_lastElement - m_firstElement); int i = m_lastElement; @@ -260,6 +264,7 @@ Trk::TrackStateOnSurfaceProtContainer::ContainerUniquePtr InDet::SiTrajectory_xk::convertToSimpleTrackStateOnSurfaceForDisTrackTrigger() { auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + dtsos->reserve (1 + m_lastElement - m_firstElement); int i = m_firstElement; @@ -2173,12 +2178,14 @@ InDet::SiTrajectory_xk::convertToNextTrackStateOnSurface() } auto dtsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + dtsos->reserve (m_ntos); if (i==m_ntos) { dtsos->elt_allocator().protect(); return dtsos; } + dtsos->reserve (m_ntos); for (i=0; i!=m_ntos; ++i) { auto tsos = m_elements[m_atos[i]].tsos(*dtsos, m_itos[i]); diff --git a/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetAmbiTrackSelectionTool.cxx b/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetAmbiTrackSelectionTool.cxx index dd4bfb998e74ee29fd1e88af8814559b5d1a8ffb..1773440710982d5b47fad4bf5995aade9069057a 100755 --- a/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetAmbiTrackSelectionTool.cxx +++ b/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetAmbiTrackSelectionTool.cxx @@ -556,6 +556,7 @@ Trk::Track* InDet::InDetAmbiTrackSelectionTool::createSubTrack( const std::vecto } auto vecTsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + vecTsos->reserve (tsos.size()); // loop over TSOS, copy TSOS and push into vector for (const Trk::TrackStateOnSurface* tsosIt : tsos) { diff --git a/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetDenseEnvAmbiTrackSelectionTool.cxx b/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetDenseEnvAmbiTrackSelectionTool.cxx index f7428d7899e4d2478501385d242fdaf464ddb874..20e02edfa117e70f0851dc9a9b4e855d5a4e6ad8 100644 --- a/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetDenseEnvAmbiTrackSelectionTool.cxx +++ b/InnerDetector/InDetRecTools/InDetAmbiTrackSelectionTool/src/InDetDenseEnvAmbiTrackSelectionTool.cxx @@ -1488,6 +1488,7 @@ Trk::Track* InDet::InDetDenseEnvAmbiTrackSelectionTool::createSubTrack( const st } auto vecTsos = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + vecTsos->reserve (tsos.size()); // loop over TSOS, copy TSOS and push into vector for (const Trk::TrackStateOnSurface* iTsos : tsos) { diff --git a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx index 1980f9aa6579a24e08ca226bdbbc36eab38f8de8..8d4124ba60ad59bf53eadc693e5227f5e4ffbfb7 100644 --- a/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx +++ b/Tracking/TrkFitter/TrkGaussianSumFilter/src/GaussianSumFitter.cxx @@ -356,6 +356,7 @@ Trk::GaussianSumFitter::fit( // Store only TSOS in tracks instead of MCSOS if (!m_StoreMCSOS) { auto slimmedSmoothedTrajectory = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + slimmedSmoothedTrajectory->reserve (smoothedTrajectory->size()); for (const Trk::TrackStateOnSurface* tsos : *smoothedTrajectory) { slimmedSmoothedTrajectory->push_back(slimmedSmoothedTrajectory->allocate(*tsos)); } @@ -494,6 +495,7 @@ Trk::GaussianSumFitter::fit( // Store only TSOS in tracks instead of MCSOS if (!m_StoreMCSOS) { auto slimmedSmoothedTrajectory = Trk::TrackStateOnSurfaceProtContainer::make_unique(); + slimmedSmoothedTrajectory->reserve (smoothedTrajectory->size()); for (const Trk::TrackStateOnSurface* tsos : *smoothedTrajectory) { slimmedSmoothedTrajectory->push_back(slimmedSmoothedTrajectory->allocate(*tsos)); } @@ -1034,6 +1036,7 @@ Trk::GaussianSumFitter::fit( * we opt for const ptr* */ auto smoothedTrajectory = SmoothedTrajectoryProt::make_unique(); + smoothedTrajectory->reserve (5 + forwardTrajectory.size()); auto smootherPredictionMultiState = std::make_unique();