Reduce calls to LLHoverView::updateText
Basically to avoid calling LLTrans::getString 250 times per second, and seeing INFO: log_sStringTemplates_accesses: LLTrans::getString/findString called 19000 in total. INFO: log_sStringTemplates_accesses: LLTrans::getString/findString called 20000 in total. etc, every 40 seconds in the log.
This commit is contained in:
@@ -88,6 +88,7 @@
|
|||||||
//
|
//
|
||||||
const char* DEFAULT_DESC = "(No Description)";
|
const char* DEFAULT_DESC = "(No Description)";
|
||||||
const F32 DELAY_BEFORE_SHOW_TIP = 0.35f;
|
const F32 DELAY_BEFORE_SHOW_TIP = 0.35f;
|
||||||
|
const F32 DELAY_BEFORE_REFRESH_TIP = 0.50f;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Local globals
|
// Local globals
|
||||||
@@ -113,6 +114,9 @@ LLHoverView::LLHoverView(const std::string& name, const LLRect& rect)
|
|||||||
mUseHover = TRUE;
|
mUseHover = TRUE;
|
||||||
mTyping = FALSE;
|
mTyping = FALSE;
|
||||||
mHoverOffset.clearVec();
|
mHoverOffset.clearVec();
|
||||||
|
//<singu>
|
||||||
|
mLastTextHoverObject = NULL;
|
||||||
|
//</singu>
|
||||||
}
|
}
|
||||||
|
|
||||||
LLHoverView::~LLHoverView()
|
LLHoverView::~LLHoverView()
|
||||||
@@ -139,6 +143,9 @@ void LLHoverView::updateHover(LLTool* current_tool)
|
|||||||
mStartHoverPickTimer = TRUE;
|
mStartHoverPickTimer = TRUE;
|
||||||
// Clear the existing text so that we do not briefly show the wrong data.
|
// Clear the existing text so that we do not briefly show the wrong data.
|
||||||
mText.clear();
|
mText.clear();
|
||||||
|
//<singu>
|
||||||
|
mLastTextHoverObject = NULL;
|
||||||
|
//</singu>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDoneHoverPick)
|
if (mDoneHoverPick)
|
||||||
@@ -222,6 +229,18 @@ void LLHoverView::updateText()
|
|||||||
LLViewerObject* hit_object = getLastHoverObject();
|
LLViewerObject* hit_object = getLastHoverObject();
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
|
//<singu>
|
||||||
|
if (hit_object == mLastTextHoverObject &&
|
||||||
|
!(mLastTextHoverObjectTimer.getStarted() && mLastTextHoverObjectTimer.hasExpired()))
|
||||||
|
{
|
||||||
|
// mText is already up to date.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mLastTextHoverObject = hit_object;
|
||||||
|
mLastTextHoverObjectTimer.stop();
|
||||||
|
bool retrieving_data = false;
|
||||||
|
//</singu>
|
||||||
|
|
||||||
mText.clear();
|
mText.clear();
|
||||||
if ( hit_object )
|
if ( hit_object )
|
||||||
{
|
{
|
||||||
@@ -403,6 +422,7 @@ void LLHoverView::updateText()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.append(LLTrans::getString("RetrievingData"));
|
line.append(LLTrans::getString("RetrievingData"));
|
||||||
|
retrieving_data = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -417,12 +437,14 @@ void LLHoverView::updateText()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.append(LLTrans::getString("RetrievingData"));
|
line.append(LLTrans::getString("RetrievingData"));
|
||||||
|
retrieving_data = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.append(LLTrans::getString("RetrievingData"));
|
line.append(LLTrans::getString("RetrievingData"));
|
||||||
|
retrieving_data = true;
|
||||||
}
|
}
|
||||||
mText.push_back(line);
|
mText.push_back(line);
|
||||||
|
|
||||||
@@ -514,6 +536,7 @@ void LLHoverView::updateText()
|
|||||||
{
|
{
|
||||||
LLStringUtil::format_map_t args;
|
LLStringUtil::format_map_t args;
|
||||||
args["[MESSAGE]"] = LLTrans::getString("RetrievingData");
|
args["[MESSAGE]"] = LLTrans::getString("RetrievingData");
|
||||||
|
retrieving_data = true;
|
||||||
line.append(LLTrans::getString("TooltipForSaleMsg", args));
|
line.append(LLTrans::getString("TooltipForSaleMsg", args));
|
||||||
}
|
}
|
||||||
mText.push_back(line);
|
mText.push_back(line);
|
||||||
@@ -604,6 +627,7 @@ void LLHoverView::updateText()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.append(LLTrans::getString("RetrievingData"));
|
line.append(LLTrans::getString("RetrievingData"));
|
||||||
|
retrieving_data = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(gCacheName->getFullName(owner, name))
|
else if(gCacheName->getFullName(owner, name))
|
||||||
@@ -616,11 +640,13 @@ void LLHoverView::updateText()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.append(LLTrans::getString("RetrievingData"));
|
line.append(LLTrans::getString("RetrievingData"));
|
||||||
|
retrieving_data = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
line.append(LLTrans::getString("RetrievingData"));
|
line.append(LLTrans::getString("RetrievingData"));
|
||||||
|
retrieving_data = true;
|
||||||
}
|
}
|
||||||
mText.push_back(line);
|
mText.push_back(line);
|
||||||
|
|
||||||
@@ -699,8 +725,15 @@ void LLHoverView::updateText()
|
|||||||
mText.push_back(line);
|
mText.push_back(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
//<singu>
|
||||||
|
if (retrieving_data)
|
||||||
|
{
|
||||||
|
// Keep doing this twice per second, until all data was retrieved.
|
||||||
|
mLastTextHoverObjectTimer.start(DELAY_BEFORE_REFRESH_TIP);
|
||||||
|
}
|
||||||
|
//</singu>
|
||||||
|
}
|
||||||
|
|
||||||
void LLHoverView::draw()
|
void LLHoverView::draw()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ protected:
|
|||||||
|
|
||||||
// If not null and not dead, we're over an object.
|
// If not null and not dead, we're over an object.
|
||||||
LLPointer<LLViewerObject> mLastHoverObject;
|
LLPointer<LLViewerObject> mLastHoverObject;
|
||||||
|
LLViewerObject* mLastTextHoverObject; // Singu extension: the value of mLastHoverObject that corresponds to mText.
|
||||||
|
LLFrameTimer mLastTextHoverObjectTimer; // Singu extension: times how long ago the text was updated (while retrieving data).
|
||||||
LLPickInfo mLastPickInfo;
|
LLPickInfo mLastPickInfo;
|
||||||
|
|
||||||
// If not LLVector3d::ZERO, we're over land.
|
// If not LLVector3d::ZERO, we're over land.
|
||||||
|
|||||||
Reference in New Issue
Block a user