Performance tweaks: do not allocate strings where they can be const. Partly from davep, SH-2652.

ziree 2011-12-10 00:26:39 +01:00
parent c26cafa84a
commit 8bd0295f3d
11 changed files with 18 additions and 12 deletions

View File

@ -269,7 +269,7 @@ public:
std::string getHoverText() const { return mHoverText; };
std::string getHoverLink() const { return mHoverLink; };
std::string getMediaName() const { return mMediaName; };
const std::string& getMediaName() const { return mMediaName; };
std::string getMediaDescription() const { return mMediaDescription; };
// Crash the plugin. If you use this outside of a testbed, you will be punished.

View File

@ -2690,7 +2690,11 @@ BOOL LLTextSegment::handleDoubleClick(S32 x, S32 y, MASK mask) { return FALSE; }
BOOL LLTextSegment::handleHover(S32 x, S32 y, MASK mask) { return FALSE; }
BOOL LLTextSegment::handleScrollWheel(S32 x, S32 y, S32 clicks) { return FALSE; }
BOOL LLTextSegment::handleToolTip(S32 x, S32 y, MASK mask) { return FALSE; }
std::string LLTextSegment::getName() const { return ""; }
const std::string& LLTextSegment::getName() const
{
static std::string empty_string("");
return empty_string;
}
void LLTextSegment::onMouseCaptureLost() {}
void LLTextSegment::screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const {}
void LLTextSegment::localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const {}

View File

@ -90,7 +90,7 @@ public:
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
/*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
/*virtual*/ std::string getName() const;
/*virtual*/ const std::string& getName() const;
/*virtual*/ void onMouseCaptureLost();
/*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const;
/*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const;

View File

@ -225,9 +225,11 @@ BOOL LLView::getUseBoundingRect() const
}
// virtual
std::string LLView::getName() const
const std::string& LLView::getName() const
{
return mName.empty() ? std::string("(no name)") : mName;
static std::string no_name("(no name)");
return mName.empty() ? no_name : mName;
}
void LLView::sendChildToFront(LLView* child)

View File

@ -433,7 +433,7 @@ public:
/*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
/*virtual*/ std::string getName() const;
/*virtual*/ const std::string& getName() const;
/*virtual*/ void onMouseCaptureLost();
/*virtual*/ BOOL hasMouseCapture();
/*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const;

View File

@ -65,7 +65,7 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask) = 0;
virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) = 0;
virtual BOOL handleToolTip(S32 x, S32 y, MASK mask) = 0;
virtual std::string getName() const = 0;
virtual const std::string& getName() const = 0;
virtual void onMouseCaptureLost() = 0;

View File

@ -676,7 +676,7 @@ LLViewerInventoryItem * LLFolderViewItem::getInventoryItem(void)
return gInventory.getItem(getListener()->getUUID());
}
std::string LLFolderViewItem::getName( void ) const
const std::string& LLFolderViewItem::getName( void ) const
{
if(mListener)
{

View File

@ -273,7 +273,7 @@ public:
// This method returns the actual name of the thing being
// viewed. This method will ask the viewed object itself.
std::string getName( void ) const;
const std::string& getName( void ) const;
const std::string& getSearchableLabel( void ) const;

View File

@ -68,7 +68,7 @@ public:
virtual void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const
{ *screen_x = local_x; *screen_y = local_y; }
virtual std::string getName() const { return mName; }
virtual const std::string& getName() const { return mName; }
// New virtual functions
virtual LLViewerObject* getEditingObject() { return NULL; }

View File

@ -2523,7 +2523,7 @@ void LLViewerMediaImpl::updateJavascriptObject()
}
//////////////////////////////////////////////////////////////////////////////////////////
std::string LLViewerMediaImpl::getName() const
const std::string& LLViewerMediaImpl::getName() const
{
if (mMediaSource)
{

View File

@ -317,7 +317,7 @@ public:
/*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask) { return FALSE; };
/*virtual*/ BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; };
/*virtual*/ BOOL handleMiddleMouseUp(S32 x, S32 y, MASK mask) {return FALSE; };
/*virtual*/ std::string getName() const;
/*virtual*/ const std::string& getName() const;
/*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const {};
/*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const {};