Skip to content

[PWGLF] Use const& and std::move to avoid copies - #17711

Open
vkucera wants to merge 2 commits into
AliceO2Group:masterfrom
vkucera:const-PWGLF
Open

[PWGLF] Use const& and std::move to avoid copies#17711
vkucera wants to merge 2 commits into
AliceO2Group:masterfrom
vkucera:const-PWGLF

Conversation

@vkucera

@vkucera vkucera commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Mostly done automatically by Clang-Tidy.

Mostly done automatically by Clang-Tidy.
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

O2 linter results: ❌ 2449 errors, ⚠️ 2010 warnings, 🔕 8 disabled

@github-actions github-actions Bot added the pwglf label Sep 1, 2026
@github-actions github-actions Bot changed the title Use const& and std::move to avoid copies [PWGLF] Use const& and std::move to avoid copies Sep 1, 2026
@vkucera
vkucera marked this pull request as ready for review September 1, 2026 15:54
romainschotter
romainschotter previously approved these changes Sep 1, 2026
@romainschotter
romainschotter enabled auto-merge (squash) September 1, 2026 19:31
@alibuild

alibuild commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for 1ca779b at 2026-09-03 21:58:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'Found 526 errors and 4094 warnings.'
Found 526 errors and 4094 warnings.
++ [[ 526 -gt 0 ]]
++ cat /sw/BUILD/862e6d91a891848d0bb88d70ff4bafe70c0aae51/O2Physics-code-check/errors.txt
PWGLF/TableProducer/Common/epvector.cxx:62:8: error: constructor does not initialize these fields: ccdb, offsetFT0, offsetFV0, gainprofile, hrecentere, shiftprofile, shiftprofile2, shiftprofile3, shiftprofile4, shiftprofile5 [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:195:7: error: variable 'pidCuts' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:199:22: error: variable 'hNsigma' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:200:22: error: variable 'hTOFmass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:201:22: error: variable 'hGenNuclei' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:202:22: error: variable 'hMomRes' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:203:22: error: variable 'hNsigmaEta' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:204:22: error: variable 'hTOFmassEta' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:205:22: error: variable 'hDCAxy' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:206:22: error: variable 'hDCAz' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:207:22: error: variable 'hGloTOFtracks' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:208:22: error: variable 'hDeltaP' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:209:28: error: variable 'hDCAHists' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:210:27: error: variable 'lut' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:210:27: error: variable 'lut' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:212:31: error: variable 'candidates' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:250:8: error: constructor does not initialize these fields: ccdb, pdgDB [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:277:58: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:289:70: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:296:77: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:299:100: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:300:82: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:301:72: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:302:67: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:304:63: error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:802:7: error: uninitialized record type: 'nSigmaTPC' [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:823:7: error: uninitialized record type: 'dcaInfo' [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:80:34: error: variable 'metadataInfo' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:201:3: error: constructor does not initialize these fields: betheParams, trkSettings [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:10: error: std::move of the const variable 'name_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:28: error: std::move of the const variable 'daughters_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:51: error: std::move of the const variable 'daughterTrackSigns_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:83: error: std::move of the const variable 'v0DaughterVec_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:233:10: error: std::move of the const variable 'name_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:233:28: error: std::move of the const variable 'daughters_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:233:51: error: std::move of the const variable 'daughterTrackSigns_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:256:30: error: Address of stack memory associated with temporary object of type 'TString' returned to caller [clang-analyzer-core.StackAddressEscape,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:257:33: error: Address of stack memory associated with temporary object of type 'TString' returned to caller [clang-analyzer-core.StackAddressEscape,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:268:3: error: constructor does not initialize these fields: dcaToPv, dcaToPvXY, dcaToPvZ, active [cppcoreguidelines-pro-type-member-init,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:486:5: error: 'itBegin' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:508:35: error: variable 'hDeDx' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:509:35: error: variable 'hInvMass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables,-warnings-as-errors]
[0 more errors; see full log]

Full log here.

@vkucera

vkucera commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Ping

@alibuild

alibuild commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for 830ad23 at 2026-09-09 19:38:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'Found 17 errors and 4069 warnings.'
Found 17 errors and 4069 warnings.
++ [[ 17 -gt 0 ]]
++ cat /sw/BUILD/7422349999db283aca217c8ed95891a436f1f037/O2Physics-code-check/errors.txt
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:10: error: std::move of the const variable 'name_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:28: error: std::move of the const variable 'daughters_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:51: error: std::move of the const variable 'daughterTrackSigns_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:225:83: error: std::move of the const variable 'v0DaughterVec_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:233:10: error: std::move of the const variable 'name_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:233:28: error: std::move of the const variable 'daughters_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:233:51: error: std::move of the const variable 'daughterTrackSigns_' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:256:30: error: Address of stack memory associated with temporary object of type 'TString' returned to caller [clang-analyzer-core.StackAddressEscape,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:257:33: error: Address of stack memory associated with temporary object of type 'TString' returned to caller [clang-analyzer-core.StackAddressEscape,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx:749:9: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx:59:3: error: 3 uninitialized fields at the end of the constructor call [clang-analyzer-optin.cplusplus.UninitializedObject,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx:457:7: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors]
PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx:505:7: error: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop [performance-inefficient-vector-operation,-warnings-as-errors]
PWGLF/Tasks/Nuspex/QAHistTask.cxx:740:11: error: Value stored to 'pdgbin' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGLF/Tasks/Resonances/kstarInOO.cxx:63:8: error: Excessive padding in 'struct kstarInOO' (36 padding bytes, where 4 is optimal). Optimal fields order: cache, massKa, massPi, eventSelectionBits, RealTriggerMaskBits, triggerMaskBitsTest1, triggerMaskBitsTest2, triggerMaskBitsTest3, JEPosZFilter, JEMCPosZFilter, JetCuts, cfgEventVtxCut, cfgEventMaxEta, cfgTrackMinPt, cfgTrackMaxEta, cfgTrackMaxDCArToPVcut, cfgTrackMaxDCAzToPVcut, cfgTrackGlobalSel, cfgTrackPrimaryTrack, cfgTrackConnectedToPV, cfgTrackGlobalWoDCATrack, cfgTrackFindableTPCClusters, cfgTrackTPCCrossedRows, cfgTrackRowsOverFindable, cfgTrackTPCChi2, cfgTrackITSChi2, cfgTrackTPCPID, cfgTrackTOFPID, cfgTrackSquarePIDCut, cfgTrackCirclePIDCut, cfgTrackCircleValue, cfgTrackTOFHard, isMIDCut, cfgTrackTPCPIDnSig, cfgTrackTOFPIDnSig, cfgMIDnSig, cDebugLevel, cfgMixNMixedEvents, cfgVtxMixCut, cfgForceGenReco, cfgReqMcEffPID, cfgReqMcEffTrackQA, cfgMinvNBins, cfgMinvMin, cfgMinvMax, cfgEventCutQA, cfgTrackCutQA, cfgJetQAHistos, cfgMCHistos, cfgMixedHistos, cfgJetHistos, cfgJetMCHistos, cfgJetdRHistos, cfgCutonTrig, cfgJetpT, cfgJetR, cfgJetdR, cfgJetMaxEta, cfgSingleJet, cfgReqJets, cfgForceTrueINELgt, cfgCentAxis, cfgBinsMixMult, cfgBinsMixVtx, binsDCAz, binsDCAxy, kaon, pion, kaonMC, pionMC, doprocessDataJets, doprocessMCJets, doprocessDataSameEvent, doprocessDataMixedEvent, doprocessSameEventMC, doprocessMixedEventMC, doprocessGen, doprocessGenJets, doprocessJetQA, cfgEventSelections, cfgRealTriggerMasks, cfgTriggerMasksTest1, cfgTriggerMasksTest2, cfgTriggerMasksTest3, perCollision, histos, nJetEvents, nJetMCEvents, nEvents, nEventsMix, nEventsMC, nEventsMCMix, nEventsGen, nprocessGenEvents, ndRtest, consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding,-warnings-as-errors]
PWGLF/Tasks/Resonances/lambda1405analysis.cxx:1622:13: error: Value stored to 'sigmaPt' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGLF/Tasks/Strangeness/cascpolsp.cxx:426:11: error: Value stored to 'tagb' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
++ [[ 4069 -gt 0 ]]
++ cat /sw/BUILD/7422349999db283aca217c8ed95891a436f1f037/O2Physics-code-check/warnings.txt
PWGLF/TableProducer/Common/epvector.cxx:62:8: warning: constructor does not initialize these fields: ccdb, offsetFT0, offsetFV0, gainprofile, hrecentere, shiftprofile, shiftprofile2, shiftprofile3, shiftprofile4, shiftprofile5 [cppcoreguidelines-pro-type-member-init]
PWGLF/TableProducer/Common/epvector.cxx:219:57: warning: statement should be inside braces [readability-braces-around-statements]
PWGLF/TableProducer/Common/epvector.cxx:221:58: warning: statement should be inside braces [readability-braces-around-statements]
PWGLF/TableProducer/Common/epvector.cxx:253:22: warning: statement should be inside braces [readability-braces-around-statements]
PWGLF/TableProducer/Common/epvector.cxx:255:11: warning: statement should be inside braces [readability-braces-around-statements]
PWGLF/TableProducer/Common/epvector.cxx:264:14: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:136:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:142:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:148:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:154:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:160:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:166:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:172:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:179:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:180:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:181:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:195:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:195:7: warning: variable 'pidCuts' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:199:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:199:22: warning: variable 'hNsigma' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:200:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:200:22: warning: variable 'hTOFmass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
PWGLF/TableProducer/Nuspex/deuteronInTriggeredEvents.cxx:201:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
[0 more errors; see full log]

Full log here.

@alibuild

alibuild commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/o2 for 830ad23 at 2026-09-10 01:58:

No log files found

Full log here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants