From bd1b57fcfc3b5e968d56efa0fbef5b9a0fdaa955 Mon Sep 17 00:00:00 2001 From: Johannes Elmsheuser Date: Thu, 25 Aug 2022 12:28:05 +0200 Subject: [PATCH] Merge branch 'cppcheck.MuonSimEventAthenaPool-20220824' into 'master' MuonSimEventAthenaPool: Fix cppcheck warnings. See merge request atlas/athena!56195 (cherry picked from commit b746f181dd0486dbce4163bee065d4f7d370b49b) 0311d69e MuonSimEventAthenaPool: Fix cppcheck warnings. --- .../src/CSCSimHitCollectionCnv.cxx | 9 ++++----- .../src/MDTSimHitCollectionCnv.cxx | 9 ++++----- .../src/RPCSimHitCollectionCnv.cxx | 9 ++++----- .../src/TGCSimHitCollectionCnv.cxx | 9 ++++----- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/CSCSimHitCollectionCnv.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/CSCSimHitCollectionCnv.cxx index 93738841bed..aea614f89e3 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/CSCSimHitCollectionCnv.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/CSCSimHitCollectionCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "CSCSimHitCollectionCnv.h" @@ -68,11 +68,10 @@ CSCSimHitCollection* CSCSimHitCollectionCnv::createTransient() { AthenaHitsVector* oldColl = this->poolReadObject< AthenaHitsVector >(); size_t size = oldColl->size(); p_collection=new CSCSimHitCollection("DefaultCollectionName",size); - //p_collection->reserve(size); + p_collection->reserve(size); //do the copy - AthenaHitsVector::const_iterator it = oldColl->begin(), itEnd=oldColl->end(); - for (;it!=itEnd;it++) { - p_collection->push_back(**it); + for (const CSCSimHit* hit : *oldColl) { + p_collection->push_back(*hit); } delete oldColl; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/MDTSimHitCollectionCnv.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/MDTSimHitCollectionCnv.cxx index 064c75277d8..26d5fc96a18 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/MDTSimHitCollectionCnv.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/MDTSimHitCollectionCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "MDTSimHitCollectionCnv.h" @@ -60,11 +60,10 @@ MDTSimHitCollection* MDTSimHitCollectionCnv::createTransient() { AthenaHitsVector* oldColl = this->poolReadObject< AthenaHitsVector >(); size_t size = oldColl->size(); p_collection=new MDTSimHitCollection("DefaultCollectionName",size); - //p_collection->reserve(size); + p_collection->reserve(size); //do the copy - AthenaHitsVector::const_iterator it = oldColl->begin(), itEnd=oldColl->end(); - for (;it!=itEnd;it++) { - p_collection->push_back(**it); + for (const MDTSimHit* hit : *oldColl) { + p_collection->push_back(*hit); } delete oldColl; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/RPCSimHitCollectionCnv.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/RPCSimHitCollectionCnv.cxx index 4d3bf5dfbb5..6ec02607e73 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/RPCSimHitCollectionCnv.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/RPCSimHitCollectionCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "RPCSimHitCollectionCnv.h" @@ -68,11 +68,10 @@ RPCSimHitCollection* RPCSimHitCollectionCnv::createTransient() { AthenaHitsVector* oldColl = this->poolReadObject< AthenaHitsVector >(); size_t size = oldColl->size(); p_collection=new RPCSimHitCollection("DefaultCollectionName",size); - //p_collection->reserve(size); + p_collection->reserve(size); //do the copy - AthenaHitsVector::const_iterator it = oldColl->begin(), itEnd=oldColl->end(); - for (;it!=itEnd;it++) { - p_collection->push_back(**it); + for (const RPCSimHit* hit : *oldColl) { + p_collection->push_back(*hit); } delete oldColl; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/TGCSimHitCollectionCnv.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/TGCSimHitCollectionCnv.cxx index b544e864248..9fd8d4bf67f 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/TGCSimHitCollectionCnv.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventAthenaPool/src/TGCSimHitCollectionCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ #include "TGCSimHitCollectionCnv.h" @@ -69,11 +69,10 @@ TGCSimHitCollection* TGCSimHitCollectionCnv::createTransient() { AthenaHitsVector* oldColl = this->poolReadObject< AthenaHitsVector >(); size_t size = oldColl->size(); p_collection=new TGCSimHitCollection("DefaultCollectionName",size); - //p_collection->reserve(size); + p_collection->reserve(size); //do the copy - AthenaHitsVector::const_iterator it = oldColl->begin(), itEnd=oldColl->end(); - for (;it!=itEnd;it++) { - p_collection->push_back(**it); + for (const TGCSimHit* hit : *oldColl) { + p_collection->push_back(*hit); } delete oldColl; } -- GitLab