1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 05:19:55 +00:00

made merge operation more fluent

(cherry picked from commit 16dda281ce)
This commit is contained in:
Marc Zinnschlag 2015-08-23 13:04:42 +02:00 committed by cc9cii
parent 98cac624a9
commit e33314ad81

View file

@ -1,6 +1,8 @@
#ifndef CSM_TOOLS_MERGESTAGES_H
#define CSM_TOOLS_MERGESTAGES_H
#include <algorithm>
#include <components/to_utf8/to_utf8.hpp>
#include "../doc/stage.hpp"
@ -33,6 +35,8 @@ namespace CSMTools
MergeState& mState;
Collection& (CSMWorld::Data::*mAccessor)();
static const int stepSize = 1000;
public:
MergeIdCollectionStage (MergeState& state, Collection& (CSMWorld::Data::*accessor)());
@ -52,7 +56,16 @@ namespace CSMTools
template<typename RecordType, typename Collection>
int MergeIdCollectionStage<RecordType, Collection>::setup()
{
return 1;
const Collection& source = (mState.mSource.getData().*mAccessor)();
int size = source.getSize();
int steps = size / stepSize;
if (size % stepSize)
++steps;
return steps;
}
template<typename RecordType, typename Collection>
@ -61,9 +74,10 @@ namespace CSMTools
const Collection& source = (mState.mSource.getData().*mAccessor)();
Collection& target = (mState.mTarget->getData().*mAccessor)();
int size = source.getSize();
int begin = stage * stepSize;
int end = std::min ((stage+1) * stepSize, source.getSize());
for (int i=0; i<size; ++i)
for (int i=begin; i<end; ++i)
{
const CSMWorld::Record<RecordType>& record = source.getRecord (i);