diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2018-06-23 11:39:47 +0900 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-06-23 10:53:21 +0200 |
commit | 578e4eca82132ddbb9475409d0b1a982f61da816 (patch) | |
tree | 1447de100b2bd463295854f218ec0dab17a85029 /sccomp | |
parent | aae64e0f9cd1582c0dc31992aa22b849d2527c80 (diff) |
sccomp: Reserve enough space at once for micro-optimization
Change-Id: Ib4e178d2a0f09cb44854f1d1aad026d8394a8917
Reviewed-on: https://gerrit.libreoffice.org/56312
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'sccomp')
-rw-r--r-- | sccomp/source/solver/CoinMPSolver.cxx | 1 | ||||
-rw-r--r-- | sccomp/source/solver/DifferentialEvolution.hxx | 1 | ||||
-rw-r--r-- | sccomp/source/solver/LpsolveSolver.cxx | 1 | ||||
-rw-r--r-- | sccomp/source/solver/ParticelSwarmOptimization.hxx | 1 |
4 files changed, 4 insertions, 0 deletions
diff --git a/sccomp/source/solver/CoinMPSolver.cxx b/sccomp/source/solver/CoinMPSolver.cxx index 2b1ddd7227d7..23426e140e42 100644 --- a/sccomp/source/solver/CoinMPSolver.cxx +++ b/sccomp/source/solver/CoinMPSolver.cxx @@ -63,6 +63,7 @@ void SAL_CALL CoinMPSolver::solve() // collect variables in vector (?) std::vector<table::CellAddress> aVariableCells; + aVariableCells.reserve(maVariables.getLength()); for (sal_Int32 nPos=0; nPos<maVariables.getLength(); nPos++) aVariableCells.push_back( maVariables[nPos] ); size_t nVariables = aVariableCells.size(); diff --git a/sccomp/source/solver/DifferentialEvolution.hxx b/sccomp/source/solver/DifferentialEvolution.hxx index 2ced9b9d209e..7d18821350aa 100644 --- a/sccomp/source/solver/DifferentialEvolution.hxx +++ b/sccomp/source/solver/DifferentialEvolution.hxx @@ -76,6 +76,7 @@ public: // Initialize population with individuals that have been initialized with uniform random // noise // uniform noise means random value inside your search space + maPopulation.reserve(mnPopulationSize); for (size_t i = 0; i < mnPopulationSize; ++i) { maPopulation.emplace_back(); diff --git a/sccomp/source/solver/LpsolveSolver.cxx b/sccomp/source/solver/LpsolveSolver.cxx index 8a6d32856760..6a6c55d961ad 100644 --- a/sccomp/source/solver/LpsolveSolver.cxx +++ b/sccomp/source/solver/LpsolveSolver.cxx @@ -100,6 +100,7 @@ void SAL_CALL LpsolveSolver::solve() // collect variables in vector (?) std::vector<table::CellAddress> aVariableCells; + aVariableCells.reserve(maVariables.getLength()); for (sal_Int32 nPos=0; nPos<maVariables.getLength(); nPos++) aVariableCells.push_back( maVariables[nPos] ); size_t nVariables = aVariableCells.size(); diff --git a/sccomp/source/solver/ParticelSwarmOptimization.hxx b/sccomp/source/solver/ParticelSwarmOptimization.hxx index 6c820ab7978c..ec76474ddece 100644 --- a/sccomp/source/solver/ParticelSwarmOptimization.hxx +++ b/sccomp/source/solver/ParticelSwarmOptimization.hxx @@ -92,6 +92,7 @@ public: mfBestFitness = std::numeric_limits<float>::lowest(); + maSwarm.reserve(mnNumOfParticles); for (size_t i = 0; i < mnNumOfParticles; i++) { maSwarm.emplace_back(mnDimensionality); |