Commit 443cb2be authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Eliminate string copies from LLTextBase getText

parent a637f6c3
......@@ -69,8 +69,8 @@ public:
// "general" fields
bool getAltImageEnable() const { return mAltImageEnable; }
MediaControls getControls() const { return mControls; }
std::string getCurrentURL() const { return mCurrentURL; }
std::string getHomeURL() const { return mHomeURL; }
const std::string& getCurrentURL() const { return mCurrentURL; }
const std::string& getHomeURL() const { return mHomeURL; }
bool getAutoLoop() const { return mAutoLoop; }
bool getAutoPlay() const { return mAutoPlay; }
bool getAutoScale() const { return mAutoScale; }
......
......@@ -68,10 +68,10 @@ public:
BOOL postBuild() override;
std::string getTitle();
const std::string& getTitle();
void setTitle(const std::string& title, const std::string& hl);
void setTitleFontStyle(std::string style);
void setTitleFontStyle(const std::string& style);
void setTitleColor(const LLUIColor& color);
......@@ -155,7 +155,7 @@ BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::postBuild()
return TRUE;
}
std::string LLAccordionCtrlTab::LLAccordionCtrlTabHeader::getTitle()
const std::string& LLAccordionCtrlTab::LLAccordionCtrlTabHeader::getTitle()
{
if(mHeaderTextbox)
{
......@@ -179,7 +179,7 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitle(const std::string& t
}
}
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitleFontStyle(std::string style)
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitleFontStyle(const std::string& style)
{
if (mHeaderTextbox)
{
......@@ -508,7 +508,7 @@ void LLAccordionCtrlTab::setAccordionView(LLView* panel)
addChild(panel,0);
}
std::string LLAccordionCtrlTab::getTitle() const
const std::string& LLAccordionCtrlTab::getTitle() const
{
if (mHeader)
{
......
......@@ -109,7 +109,7 @@ public:
void setAccordionView(LLView* panel);
LLView* getAccordionView() { return mContainerPanel; };
std::string getTitle() const;
const std::string& getTitle() const;
// Set text and highlight substring in LLAccordionCtrlTabHeader
void setTitle(const std::string& title, const std::string& hl = LLStringUtil::null);
......
......@@ -191,7 +191,7 @@ void LLCheckBoxCtrl::setLabel( const LLStringExplicit& label )
reshape(getRect().getWidth(), getRect().getHeight(), FALSE);
}
std::string LLCheckBoxCtrl::getLabel() const
const std::string& LLCheckBoxCtrl::getLabel() const
{
return mLabel->getText();
}
......
......@@ -99,7 +99,7 @@ public:
void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
void setLabel( const LLStringExplicit& label );
std::string getLabel() const;
const std::string& getLabel() const;
void setFont( const LLFontGL* font ) { mFont = font; }
const LLFontGL* getFont() { return mFont; }
......
......@@ -1011,7 +1011,7 @@ void LLComboBox::updateSelection()
void LLComboBox::onTextCommit(const LLSD& data)
{
std::string text = mTextEntry->getText();
const std::string& text = mTextEntry->getText();
setSimple(text);
onCommit();
mTextEntry->selectAll();
......
......@@ -115,7 +115,7 @@ void LLDragHandleTop::setTitle(const std::string& title)
}
std::string LLDragHandleTop::getTitle() const
const std::string& LLDragHandleTop::getTitle() const
{
return mTitleBox == nullptr ? LLStringUtil::null : mTitleBox->getText();
}
......@@ -133,7 +133,7 @@ void LLDragHandleLeft::setTitle(const std::string& )
}
std::string LLDragHandleLeft::getTitle() const
const std::string& LLDragHandleLeft::getTitle() const
{
return LLStringUtil::null;
}
......
......@@ -70,7 +70,7 @@ public:
void setTitleVisible(BOOL visible);
virtual void setTitle( const std::string& title ) = 0;
virtual std::string getTitle() const = 0;
virtual const std::string& getTitle() const = 0;
BOOL handleHover(S32 x, S32 y, MASK mask) override;
BOOL handleMouseDown(S32 x, S32 y, MASK mask) override;
......@@ -109,7 +109,7 @@ protected:
friend class LLUICtrlFactory;
public:
void setTitle( const std::string& title ) override;
std::string getTitle() const override;
const std::string& getTitle() const override;
void draw() override;
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) override;
......@@ -127,7 +127,7 @@ protected:
friend class LLUICtrlFactory;
public:
void setTitle( const std::string& title ) override;
std::string getTitle() const override;
const std::string& getTitle() const override;
void draw() override;
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE) override;
......
......@@ -492,7 +492,7 @@ void LLFolderViewItem::rename(const std::string& new_name)
const std::string& LLFolderViewItem::getName( void ) const
{
static const std::string noName("");
static const std::string noName;
return getViewModelItem() ? getViewModelItem()->getName() : noName;
}
......
......@@ -2047,9 +2047,9 @@ void LLTextBase::setText(const LLStringExplicit &utf8str, const LLStyle::Params&
}
//virtual
std::string LLTextBase::getText() const
const std::string& LLTextBase::getText() const
{
return getViewModel()->getValue().asString();
return getViewModel()->getValue().asStringRef();
}
// IDEVO - icons can be UI image names or UUID sent from
......
......@@ -396,7 +396,7 @@ public:
// Text accessors
// TODO: add optional style parameter
virtual void setText(const LLStringExplicit &utf8str , const LLStyle::Params& input_params = LLStyle::Params()); // uses default style
virtual std::string getText() const;
virtual const std::string& getText() const;
void setMaxTextLength(S32 length) { mMaxTextByteLength = length; }
// wide-char versions
......
......@@ -320,7 +320,7 @@ void LLTimeCtrl::updateText()
LLTimeCtrl::EEditingPart LLTimeCtrl::getEditingPart()
{
S32 cur_pos = mEditor->getCursor();
std::string time_str = mEditor->getText();
const std::string& time_str = mEditor->getText();
size_t colon_index = time_str.find_first_of(':');
......
......@@ -121,7 +121,7 @@ public:
/**
* Returns text
*/
virtual std::string getText() const { return mText; }
virtual const std::string& getText() const { return mText; }
/**
* Sets text
......
......@@ -373,7 +373,7 @@ void LLFloaterIMNearbyChat::showHistory()
setResizeLimits(getMinWidth(), EXPANDED_MIN_HEIGHT);
}
std::string LLFloaterIMNearbyChat::getCurrentChat() const
const std::string& LLFloaterIMNearbyChat::getCurrentChat() const
{
return mInputEditor ? mInputEditor->getText() : LLStringUtil::null;
}
......
......@@ -63,7 +63,7 @@ public:
LLChatEntry* getChatBox() const { return mInputEditor; }
std::string getCurrentChat() const;
const std::string& getCurrentChat() const;
S32 getMessageArchiveLength() const {return mMessageArchive.size();}
BOOL handleKeyHere( KEY key, MASK mask ) override;
......
......@@ -1025,8 +1025,8 @@ class LLVivoxSecurity final : public LLSingleton<LLVivoxSecurity>
virtual ~LLVivoxSecurity();
public:
std::string connectorHandle() { return mConnectorHandle; };
std::string accountHandle() { return mAccountHandle; };
const std::string& connectorHandle() { return mConnectorHandle; };
const std::string& accountHandle() { return mAccountHandle; };
#ifdef LL_LINUX
void setConnectorHandle(const std::string& handle) { mConnectorHandle = handle; }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment