-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Test clang-tidy --checks performance-inefficient-vector-operation #29930
[RFC] Test clang-tidy --checks performance-inefficient-vector-operation #29930
Conversation
The code-checks are being triggered in jenkins. |
A new Pull Request was created by @fwyzard (Andrea Bocci) for master. It involves the following packages: .clang-tidy @andrius-k, @lveldere, @sbein, @schneiml, @ianna, @kpedro88, @rekovic, @fioriNTU, @tlampen, @pohsun, @santocch, @perrotta, @civanch, @makortel, @cmsbuild, @smuzaffar, @Dr15Jones, @cvuosalo, @ssekmen, @mdhildreth, @jfernan2, @tocheng, @slava77, @ggovi, @benkrikler, @kmaeshima, @christopheralanwest, @alja can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
+1 |
+1 |
+1 |
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, this is a good exercise that clearly indicates potential for code improvements.
BTW, DQM copies lots of string
s. Perhaps, using string_view
s would help with performance?
@@ -97,6 +97,8 @@ CTPPSFastTrackingProducer::CTPPSFastTrackingProducer(const edm::ParameterSet& iC | |||
|
|||
//Timing Detector Description | |||
std::vector<double> vToFCellWidth; | |||
vToFCellWidth.reserve(8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a one-line would do:
// Declaring new vector and copying
// element of old vector
// constructor method, Deep copy
std::vector<double> vToFCellWidth(fToFCellWidth);
@@ -351,6 +353,8 @@ void CTPPSFastTrackingProducer::FastReco(int Direction, H_RecRPObject* station) | |||
double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset; | |||
int cellId = 0; | |||
std::vector<double> vToFCellWidth; | |||
vToFCellWidth.reserve(8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
std::vector<double> vToFCellWidth(fToFCellWidth);
@@ -222,6 +222,8 @@ void CTPPSRecHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe | |||
double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset; | |||
|
|||
std::vector<double> vToFCellWidth; | |||
vToFCellWidth.reserve(8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
std::vector<double> vToFCellWidth(fToFCellWidth);
@@ -30,6 +30,8 @@ std::vector<ME0TriggerDigi> ME0Motherboard::readoutTriggers() { | |||
std::vector<ME0TriggerDigi> tmpV; | |||
|
|||
std::vector<ME0TriggerDigi> all_trigs = getTriggers(); | |||
tmpV.reserve(all_trigs.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
std::vector<ME0TriggerDigi> tmpV(all_trigs);
@@ -214,8 +214,12 @@ vector<int> CandOneToOneDeltaRMatcher::AlgoBruteForce(int nMin, int nMax) { | |||
float totalDeltaR = 0; | |||
float BestTotalDeltaR = 1000; | |||
|
|||
ca.reserve(nMax); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively:
std::vector<int> ca(nMax);
std::iota(ca.begin(), ca.end(), 0);
@@ -94,6 +94,8 @@ void HiGenCleaner<T2>::produce(edm::StreamID, edm::Event& iEvent, const edm::Eve | |||
int jetsize = genjets->size(); | |||
|
|||
vector<int> selection; | |||
selection.reserve(jetsize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector<int> selection(jetsize, -1);
@@ -106,6 +106,8 @@ void CalibratedPhotonProducerT<T>::fillDescriptions(edm::ConfigurationDescriptio | |||
desc.add<bool>("produceCalibratedObjs", true); | |||
desc.add<bool>("semiDeterministic", true); | |||
std::vector<std::string> valMapsProduced; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string_view
?
@@ -116,6 +116,8 @@ void CalibratedElectronProducerT<T>::fillDescriptions(edm::ConfigurationDescript | |||
desc.add<bool>("produceCalibratedObjs", true); | |||
desc.add<bool>("semiDeterministic", true); | |||
std::vector<std::string> valMapsProduced; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string_view
?
@@ -320,6 +320,8 @@ void HybridClusterAlgo::mainSearch(const EcalRecHitCollection* hits, const CaloS | |||
|
|||
std::vector<int> OwnerShip; | |||
std::vector<double> LumpEnergy; | |||
OwnerShip.reserve(int(dominoEnergy.size())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::vector<int> OwnerShip(int(dominoEnergy.size()), -1);
@@ -279,6 +279,8 @@ void DTLinearFit::fit4Var(const vector<float>& xfit, | |||
int nppar3 = 0; | |||
int nppar4 = 0; | |||
|
|||
sigy.reserve(nptfit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector<float> sigy(nptfit, sigma);
+1
(also to take this off our review list) |
|
take it in fix the issue later |
See the description at https://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-vector-operation.html .