Skip to content

Commit

Permalink
use reserve for new strucutre
Browse files Browse the repository at this point in the history
  • Loading branch information
KSkwarczynski committed Jul 17, 2024
1 parent 8b75b29 commit 5f93240
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions covariance/covarianceXsec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ void covarianceXsec::InitXsecFromConfig() {
_fParamType = std::vector<SystType>(_fNumPar);
isFlux.resize(_fNumPar);

//KS: We know at most how params we expect so reserve memory for max possible params. Later we will shrink to size to not waste memory. Reserving means slightly faster loading and possible less memory fragmentation.
NormParams.reserve(_fNumPar);
SplineParams.reserve(_fNumPar);

int i = 0;
//ETA - read in the systematics. Would be good to add in some checks to make sure
//that there are the correct number of entries i.e. are the _fNumPars for Names,
Expand Down Expand Up @@ -80,6 +84,10 @@ void covarianceXsec::InitXsecFromConfig() {
else isFlux[i] = false;
i++;
}

NormParams.shrink_to_fit();
SplineParams.shrink_to_fit();

return;
}

Expand Down

0 comments on commit 5f93240

Please sign in to comment.