Cache the lookup of the sim access level.

Being part of the state line, it is called every frame, causing a
translation lookup every frame.
This commit is contained in:
Aleric Inglewood
2013-11-05 02:19:57 +01:00
parent 66a43ea537
commit 54b43f1ad7
2 changed files with 12 additions and 4 deletions

View File

@@ -599,9 +599,15 @@ BOOL LLViewerRegion::canManageEstate() const
|| gAgent.getID() == getOwner(); || gAgent.getID() == getOwner();
} }
const std::string LLViewerRegion::getSimAccessString() const std::string const& LLViewerRegion::getSimAccessString()
{ {
return accessToString(mSimAccess); // Singu: added a cache because this is called every frame.
if (mLastSimAccess != mSimAccess)
{
mSimAccessString = accessToString(mSimAccess);
mLastSimAccess = mSimAccess;
}
return mSimAccessString;
} }
std::string LLViewerRegion::getLocalizedSimProductName() const std::string LLViewerRegion::getLocalizedSimProductName() const

View File

@@ -204,8 +204,8 @@ public:
void setSimAccess(U8 sim_access) { mSimAccess = sim_access; } void setSimAccess(U8 sim_access) { mSimAccess = sim_access; }
U8 getSimAccess() const { return mSimAccess; } U8 getSimAccess() const { return mSimAccess; }
const std::string getSimAccessString() const; std::string const& getSimAccessString(); // Singu note: return reference to mSimAccessString.
// Homestead-related getters; there are no setters as nobody should be // Homestead-related getters; there are no setters as nobody should be
// setting them other than the individual message handler which is a member // setting them other than the individual message handler which is a member
S32 getSimClassID() const { return mClassID; } S32 getSimClassID() const { return mClassID; }
@@ -425,6 +425,8 @@ private:
U64 mRegionFlags; // includes damage flags U64 mRegionFlags; // includes damage flags
U64 mRegionProtocols; // protocols supported by this region U64 mRegionProtocols; // protocols supported by this region
U8 mSimAccess; U8 mSimAccess;
U8 mLastSimAccess; // Singularity extension.
std::string mSimAccessString; // Singularity extension.
F32 mBillableFactor; F32 mBillableFactor;
U32 mMaxTasks; // max prim count U32 mMaxTasks; // max prim count
F32 mCameraDistanceSquared; // updated once per frame F32 mCameraDistanceSquared; // updated once per frame