1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 19:11:32 +00:00

removes useless make_tuple, and changes type of typeIndex to size_t

This commit is contained in:
florent.teppe 2022-09-03 13:32:44 +02:00
parent 31330c9abc
commit 85a9edf2ee
2 changed files with 8 additions and 10 deletions

View file

@ -271,10 +271,8 @@ namespace MWWorld
static int AssignStoreToIndex(ESMStore& stores, Store<T>& store) static int AssignStoreToIndex(ESMStore& stores, Store<T>& store)
{ {
const int storeIndex = ESMStore::getTypeIndex<T>(); const int storeIndex = ESMStore::getTypeIndex<T>();
assert(ESMStore::getTypeIndex<T>() == storeIndex); if (stores.mStores.size() <= storeIndex)
const std::size_t index_t(storeIndex); stores.mStores.resize(storeIndex + 1);
if (stores.mStores.size() <= index_t)
stores.mStores.resize(index_t + 1);
assert(&store == &std::get<Store<T>>(stores.mStoreImp->mStores)); assert(&store == &std::get<Store<T>>(stores.mStoreImp->mStores));
@ -330,7 +328,7 @@ namespace MWWorld
ESMStore::ESMStore() ESMStore::ESMStore()
{ {
mStoreImp = std::make_unique<ESMStoreImp>(*this); mStoreImp = std::make_unique<ESMStoreImp>(*this);
std::apply([this](auto& ...x){std::make_tuple(ESMStoreImp::AssignStoreToIndex(*this, x)...);} , mStoreImp->mStores); std::apply([this](auto& ...x) {(ESMStoreImp::AssignStoreToIndex(*this, x), ...); }, mStoreImp->mStores);
mDynamicCount = 0; mDynamicCount = 0;
mStoreImp->SetupAfterStoresCreation(*this); mStoreImp->SetupAfterStoresCreation(*this);
getWritable<ESM::Pathgrid>().setCells(getWritable<ESM::Cell>()); getWritable<ESM::Pathgrid>().setCells(getWritable<ESM::Cell>());
@ -437,9 +435,9 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener, ESM::Dialo
} }
} }
static int sTypeIndexCounter = 0; static std::size_t sTypeIndexCounter = 0;
int& ESMStore::getTypeIndexCounter() std::size_t& ESMStore::getTypeIndexCounter()
{ {
return sTypeIndexCounter; return sTypeIndexCounter;
} }

View file

@ -31,12 +31,12 @@ namespace MWWorld
{ {
friend struct ESMStoreImp; //This allows StoreImp to extend esmstore without beeing included everywhere friend struct ESMStoreImp; //This allows StoreImp to extend esmstore without beeing included everywhere
static int& getTypeIndexCounter(); static std::size_t &getTypeIndexCounter();
template<typename T> template<typename T>
static int getTypeIndex() static std::size_t getTypeIndex()
{ {
static int index = getTypeIndexCounter()++; static std::size_t index = getTypeIndexCounter()++;
return index; return index;
} }