mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
made merge operation more fluent
This commit is contained in:
parent
103073150e
commit
16dda281ce
1 changed files with 17 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
#ifndef CSM_TOOLS_MERGESTAGES_H
|
#ifndef CSM_TOOLS_MERGESTAGES_H
|
||||||
#define CSM_TOOLS_MERGESTAGES_H
|
#define CSM_TOOLS_MERGESTAGES_H
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
#include "../doc/stage.hpp"
|
#include "../doc/stage.hpp"
|
||||||
|
@ -33,6 +35,8 @@ namespace CSMTools
|
||||||
MergeState& mState;
|
MergeState& mState;
|
||||||
Collection& (CSMWorld::Data::*mAccessor)();
|
Collection& (CSMWorld::Data::*mAccessor)();
|
||||||
|
|
||||||
|
static const int stepSize = 1000;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MergeIdCollectionStage (MergeState& state, Collection& (CSMWorld::Data::*accessor)());
|
MergeIdCollectionStage (MergeState& state, Collection& (CSMWorld::Data::*accessor)());
|
||||||
|
@ -52,7 +56,16 @@ namespace CSMTools
|
||||||
template<typename RecordType, typename Collection>
|
template<typename RecordType, typename Collection>
|
||||||
int MergeIdCollectionStage<RecordType, Collection>::setup()
|
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>
|
template<typename RecordType, typename Collection>
|
||||||
|
@ -61,9 +74,10 @@ namespace CSMTools
|
||||||
const Collection& source = (mState.mSource.getData().*mAccessor)();
|
const Collection& source = (mState.mSource.getData().*mAccessor)();
|
||||||
Collection& target = (mState.mTarget->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);
|
const CSMWorld::Record<RecordType>& record = source.getRecord (i);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue