diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-23 15:02:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-06-24 08:43:55 +0200 |
commit | a2fc883173d7053cefe543620982051ae40c4b03 (patch) | |
tree | dac1b760925c8151dfd8a9cbe3a8735b68ab9f79 /sccomp | |
parent | 010713e65ccade7b682c219707c8db3d864145c1 (diff) |
use more std::container::insert instead of std::copy
which is both more compact code, and more efficient, since the insert
method can do smarter resizing
Change-Id: I17f226660f87cdf002edccc29b4af8fd59a25f91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96948
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sccomp')
-rw-r--r-- | sccomp/source/solver/ParticelSwarmOptimization.hxx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sccomp/source/solver/ParticelSwarmOptimization.hxx b/sccomp/source/solver/ParticelSwarmOptimization.hxx index ec76474ddece..42782cfa5b69 100644 --- a/sccomp/source/solver/ParticelSwarmOptimization.hxx +++ b/sccomp/source/solver/ParticelSwarmOptimization.hxx @@ -113,15 +113,15 @@ public: rParticle.mPosition[k] = mrDataProvider.clampVariable(k, rParticle.mPosition[k]); } - std::copy(rParticle.mPosition.begin(), rParticle.mPosition.end(), - rParticle.mBestPosition.begin()); + rParticle.mBestPosition.insert(rParticle.mBestPosition.begin(), + rParticle.mPosition.begin(), rParticle.mPosition.end()); rParticle.mBestFitness = rParticle.mCurrentFitness; if (rParticle.mCurrentFitness > mfBestFitness) { mfBestFitness = rParticle.mCurrentFitness; - std::copy(rParticle.mPosition.begin(), rParticle.mPosition.end(), - maBestPosition.begin()); + maBestPosition.insert(maBestPosition.begin(), rParticle.mPosition.begin(), + rParticle.mPosition.end()); } } } @@ -153,8 +153,9 @@ public: if (rParticle.mCurrentFitness > rParticle.mBestFitness) { rParticle.mBestFitness = rParticle.mCurrentFitness; - std::copy(rParticle.mPosition.begin(), rParticle.mPosition.end(), - rParticle.mBestPosition.begin()); + rParticle.mBestPosition.insert(rParticle.mBestPosition.begin(), + rParticle.mPosition.begin(), + rParticle.mPosition.end()); } if (rParticle.mCurrentFitness > mfBestFitness) @@ -164,8 +165,8 @@ public: bBestChanged = true; mnLastChange = mnGeneration; } - std::copy(rParticle.mPosition.begin(), rParticle.mPosition.end(), - maBestPosition.begin()); + maBestPosition.insert(maBestPosition.begin(), rParticle.mPosition.begin(), + rParticle.mPosition.end()); mfBestFitness = rParticle.mCurrentFitness; } } |