From e16400ac63df63c84de1644d03916bb44370ecfd Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Sun, 8 Nov 2020 11:23:32 -0500 Subject: [PATCH] LArRawEvent: Fix cppcheck warnings. - Prefer to pass large objects by const reference instead of by value. - Avoid post-increment of user iterators. --- LArCalorimeter/LArRawEvent/LArRawEvent/LArRawSC.h | 6 +++--- LArCalorimeter/LArRawEvent/src/LArRawSC.cxx | 6 ++---- LArCalorimeter/LArRawEvent/src/LArRawSCContainer.cxx | 8 ++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawSC.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawSC.h index 94f115f85c6..149b38a1f27 100755 --- a/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawSC.h +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawSC.h @@ -43,7 +43,7 @@ class LArRawSC { @param[in] gain_value Gain @param[in] sample_value Reference of vector with ADC samples */ - LArRawSC(const HWIdentifier & channel_value, const short chan, const unsigned int sourceId, const std::vector < int > & energies, const std::vector<unsigned short> bcids, std::vector<bool> satur): + LArRawSC(const HWIdentifier & channel_value, const short chan, const unsigned int sourceId, const std::vector < int > & energies, const std::vector<unsigned short>& bcids, std::vector<bool>& satur): m_hardwareID(channel_value), m_chan(chan),m_sourceId(sourceId), m_energies(energies), m_BCId(bcids), m_satur(satur) {} LArRawSC(const HWIdentifier & channel_value, @@ -87,12 +87,12 @@ class LArRawSC { /** @brief Set energies . @param[in] samples vector of energies */ - void setEnergies( std::vector < int > energies); + void setEnergies( const std::vector < int >& energies); /** @brief Set bcids. @param[in] samples vector of bcids */ - void setBCIds( std::vector < unsigned short > bcids); + void setBCIds( const std::vector < unsigned short >& bcids); /** @brief Destructor */ virtual ~LArRawSC() { } diff --git a/LArCalorimeter/LArRawEvent/src/LArRawSC.cxx b/LArCalorimeter/LArRawEvent/src/LArRawSC.cxx index f09c03c9ce7..2f38bcff07a 100755 --- a/LArCalorimeter/LArRawEvent/src/LArRawSC.cxx +++ b/LArCalorimeter/LArRawEvent/src/LArRawSC.cxx @@ -35,14 +35,12 @@ LArRawSC::operator std::string() const{ } // set method -void LArRawSC::setEnergies(std::vector<int> energies) +void LArRawSC::setEnergies(const std::vector<int>& energies) { - m_energies.clear(); m_energies = energies; } -void LArRawSC::setBCIds(std::vector<unsigned short> bcids) +void LArRawSC::setBCIds(const std::vector<unsigned short>& bcids) { - m_BCId.clear(); m_BCId = bcids; } diff --git a/LArCalorimeter/LArRawEvent/src/LArRawSCContainer.cxx b/LArCalorimeter/LArRawEvent/src/LArRawSCContainer.cxx index 1117287a766..144286241c5 100755 --- a/LArCalorimeter/LArRawEvent/src/LArRawSCContainer.cxx +++ b/LArCalorimeter/LArRawEvent/src/LArRawSCContainer.cxx @@ -24,12 +24,8 @@ LArRawSCContainer::operator std::string () const { LArRawSCContainer::const_iterator it ; int counter = 0 ; - const LArRawSC * digit ; - - for(it = this->begin() ; it != this->end() ; it++ ){ // Loop over Hits - - digit = *it ; - + + for (const LArRawSC * digit : *this) { // Loop over Hits sprintf( stCounter , "%d" , counter ) ; digitContainerString += "LArRawSC[" ; -- GitLab