[Libreoffice-commits] core.git: sccomp/source

Takeshi Abe tabe at fixedpoint.jp
Sat Jun 23 08:53:41 UTC 2018


 sccomp/source/solver/CoinMPSolver.cxx              |    1 +
 sccomp/source/solver/DifferentialEvolution.hxx     |    1 +
 sccomp/source/solver/LpsolveSolver.cxx             |    1 +
 sccomp/source/solver/ParticelSwarmOptimization.hxx |    1 +
 4 files changed, 4 insertions(+)

New commits:
commit 578e4eca82132ddbb9475409d0b1a982f61da816
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sat Jun 23 11:39:47 2018 +0900

    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 at collabora.co.uk>
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

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);


More information about the Libreoffice-commits mailing list