1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-02 04:15:34 +00:00
openmw/apps/opencs/model/world/refcollection.hpp
cc9cii 5c504e4d22 Convert the CellRef record index lookup maps to use integer keys rather than strings.
- Morrowind load over 300,000 references, so even small inefficiencies add up to longer loading times.
- std::map is used, but should try others, std::unordered_map or even std::vector

(copied the changes from commit SHA-1: 86945d1912)
2021-07-23 19:07:56 +10:00

70 lines
2.2 KiB
C++

#ifndef CSM_WOLRD_REFCOLLECTION_H
#define CSM_WOLRD_REFCOLLECTION_H
#include <map>
#include "../doc/stage.hpp"
#include "collection.hpp"
#include "ref.hpp"
#include "record.hpp"
namespace CSMWorld
{
struct Cell;
class UniversalId;
template<>
void Collection<CellRef, IdAccessor<CellRef> >::removeRows (int index, int count);
template<>
void Collection<CellRef, IdAccessor<CellRef> >::insertRecord (std::unique_ptr<RecordBase> record, int index,
UniversalId::Type type);
/// \brief References in cells
class RefCollection : public Collection<CellRef>
{
Collection<Cell>& mCells;
std::map<unsigned int, int> mRefIndex;
int mNextId;
unsigned int extractIdNum(const std::string& id) const;
int getIntIndex (unsigned int id) const;
int searchId (unsigned int id) const;
public:
// MSVC needs the constructor for a class inheriting a template to be defined in header
RefCollection (Collection<Cell>& cells)
: mCells (cells), mNextId (0)
{}
void load (ESM::ESMReader& reader, int cellIndex, bool base,
std::map<unsigned int, unsigned int>& cache, CSMDoc::Messages& messages);
///< Load a sequence of references.
std::string getNewId();
virtual void removeRows (int index, int count);
virtual void appendBlankRecord (const std::string& id,
UniversalId::Type type = UniversalId::Type_None);
virtual void cloneRecord (const std::string& origin,
const std::string& destination,
const UniversalId::Type type);
virtual int searchId (const std::string& id) const;
virtual void appendRecord (std::unique_ptr<RecordBase> record,
UniversalId::Type type = UniversalId::Type_None);
virtual void insertRecord (std::unique_ptr<RecordBase> record,
int index,
UniversalId::Type type = UniversalId::Type_None);
};
}
#endif