mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 00:06:43 +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:
parent
b6d2888c48
commit
11166a1a17
2 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "containerstore.hpp"
|
#include "containerstore.hpp"
|
||||||
|
|
||||||
|
const std::string MWWorld::Ptr::sEmptyString;
|
||||||
|
|
||||||
ESM::CellRef& MWWorld::Ptr::getCellRef() const
|
ESM::CellRef& MWWorld::Ptr::getCellRef() const
|
||||||
{
|
{
|
||||||
assert (mCellRef);
|
assert (mCellRef);
|
||||||
|
|
|
@ -11,6 +11,8 @@ namespace MWWorld
|
||||||
|
|
||||||
class Ptr
|
class Ptr
|
||||||
{
|
{
|
||||||
|
static const std::string sEmptyString;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef MWWorld::CellStore CellStore;
|
typedef MWWorld::CellStore CellStore;
|
||||||
|
@ -20,7 +22,6 @@ namespace MWWorld
|
||||||
ESM::CellRef *mCellRef;
|
ESM::CellRef *mCellRef;
|
||||||
RefData *mRefData;
|
RefData *mRefData;
|
||||||
CellStore *mCell;
|
CellStore *mCell;
|
||||||
std::string mTypeName;
|
|
||||||
ContainerStore *mContainerStore;
|
ContainerStore *mContainerStore;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -34,7 +35,7 @@ namespace MWWorld
|
||||||
|
|
||||||
const std::string& getTypeName() const
|
const std::string& getTypeName() const
|
||||||
{
|
{
|
||||||
return mTypeName;
|
return mPtr ? mPtr->mTypeName : sEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -45,7 +46,6 @@ namespace MWWorld
|
||||||
mCellRef = &liveCellRef->mRef;
|
mCellRef = &liveCellRef->mRef;
|
||||||
mRefData = &liveCellRef->mData;
|
mRefData = &liveCellRef->mData;
|
||||||
mCell = cell;
|
mCell = cell;
|
||||||
mTypeName = typeid (T).name();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in a new issue