1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

Don't store the type name string in the Ptr

This should get rid of all heap allocations caused by constructing or copying
Ptr objects.
This commit is contained in:
Chris Robinson 2013-08-13 06:42:02 -07:00
parent b6d2888c48
commit 11166a1a17
2 changed files with 5 additions and 3 deletions

View file

@ -5,6 +5,8 @@
#include "containerstore.hpp"
const std::string MWWorld::Ptr::sEmptyString;
ESM::CellRef& MWWorld::Ptr::getCellRef() const
{
assert (mCellRef);

View file

@ -11,6 +11,8 @@ namespace MWWorld
class Ptr
{
static const std::string sEmptyString;
public:
typedef MWWorld::CellStore CellStore;
@ -20,7 +22,6 @@ namespace MWWorld
ESM::CellRef *mCellRef;
RefData *mRefData;
CellStore *mCell;
std::string mTypeName;
ContainerStore *mContainerStore;
public:
@ -34,7 +35,7 @@ namespace MWWorld
const std::string& getTypeName() const
{
return mTypeName;
return mPtr ? mPtr->mTypeName : sEmptyString;
}
template<typename T>
@ -45,7 +46,6 @@ namespace MWWorld
mCellRef = &liveCellRef->mRef;
mRefData = &liveCellRef->mData;
mCell = cell;
mTypeName = typeid (T).name();
}
template<typename T>