From 54b43f1ad7c7649ebba9e10767cf1e597c539a9e Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Tue, 5 Nov 2013 02:19:57 +0100 Subject: [PATCH] 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. --- indra/newview/llviewerregion.cpp | 10 ++++++++-- indra/newview/llviewerregion.h | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 9402996b4..4146aa40b 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -599,9 +599,15 @@ BOOL LLViewerRegion::canManageEstate() const || 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 diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 6b0e73b49..8209a4dbe 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -204,8 +204,8 @@ public: void setSimAccess(U8 sim_access) { mSimAccess = sim_access; } 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 // setting them other than the individual message handler which is a member S32 getSimClassID() const { return mClassID; } @@ -425,6 +425,8 @@ private: U64 mRegionFlags; // includes damage flags U64 mRegionProtocols; // protocols supported by this region U8 mSimAccess; + U8 mLastSimAccess; // Singularity extension. + std::string mSimAccessString; // Singularity extension. F32 mBillableFactor; U32 mMaxTasks; // max prim count F32 mCameraDistanceSquared; // updated once per frame