Reduce string temporaries from LLTabContainer, LLMenuGL, LLLayoutStack, and LLKeywords using string_view

meow-7.2.2
Rye Mutt 2024-07-02 08:56:42 -04:00
parent 6ad1957b31
commit 14cbf331cb
9 changed files with 23 additions and 23 deletions

View File

@ -164,13 +164,13 @@ std::string LLKeywords::getArguments(LLSD& arguments)
return argString;
}
std::string LLKeywords::getAttribute(const std::string& key)
std::string LLKeywords::getAttribute(std::string_view key)
{
attribute_iterator_t it = mAttributes.find(key);
return (it != mAttributes.end()) ? it->second : "";
}
LLColor4 LLKeywords::getColorGroup(const std::string& key_in)
LLColor4 LLKeywords::getColorGroup(std::string_view key_in)
{
std::string color_group = "ScriptText";
if (key_in == "functions")
@ -261,7 +261,7 @@ void LLKeywords::processTokens()
LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL;
}
void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group)
void LLKeywords::processTokensGroup(const LLSD& tokens, std::string_view group)
{
LLColor4 color;
LLColor4 color_group;
@ -333,7 +333,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group
case LLKeywordToken::TT_CONSTANT:
if (getAttribute("type").length() > 0)
{
color_group = getColorGroup(group + "-" + getAttribute("type"));
color_group = getColorGroup(std::string(group) + "-" + getAttribute("type"));
}
else
{

View File

@ -111,7 +111,7 @@ public:
~LLKeywords();
void clearLoaded() { mLoaded = false; }
LLColor4 getColorGroup(const std::string& key_in);
LLColor4 getColorGroup(std::string_view key_in);
bool isLoaded() const { return mLoaded; }
void findSegments(std::vector<LLTextSegmentPtr> *seg_list,
@ -170,7 +170,7 @@ public:
#endif
protected:
void processTokensGroup(const LLSD& Tokens, const std::string& Group);
void processTokensGroup(const LLSD& Tokens, std::string_view Group);
void insertSegment(std::vector<LLTextSegmentPtr>& seg_list,
LLTextSegmentPtr new_segment,
S32 text_len,
@ -194,10 +194,10 @@ protected:
token_list_t mLineTokenList;
token_list_t mDelimiterTokenList;
typedef std::map<std::string, std::string> element_attributes_t;
typedef std::map<std::string, std::string, std::less<>> element_attributes_t;
typedef element_attributes_t::const_iterator attribute_iterator_t;
element_attributes_t mAttributes;
std::string getAttribute(const std::string& key);
std::string getAttribute(std::string_view key);
std::string getArguments(LLSD& arguments);
};

View File

@ -548,7 +548,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const
return NULL;
}
LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) const
LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(std::string_view name) const
{
LLLayoutPanel* result = NULL;

View File

@ -111,7 +111,7 @@ private:
e_panel_list_t mPanels;
LLLayoutPanel* findEmbeddedPanel(LLPanel* panelp) const;
LLLayoutPanel* findEmbeddedPanelByName(const std::string& name) const;
LLLayoutPanel* findEmbeddedPanelByName(std::string_view name) const;
void updateFractionalSizes();
void normalizeFractionalSizes();
void updatePanelRect( LLLayoutPanel* param1, const LLRect& new_rect );

View File

@ -2752,7 +2752,7 @@ void LLMenuGL::setEnabledSubMenus(bool enable)
// setItemEnabled() - pass the label and the enable flag for a menu
// item. true will make sure it's enabled, false will disable it.
void LLMenuGL::setItemEnabled( const std::string& name, bool enable )
void LLMenuGL::setItemEnabled(std::string_view name, bool enable )
{
item_list_t::iterator item_iter;
for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter)
@ -2766,7 +2766,7 @@ void LLMenuGL::setItemEnabled( const std::string& name, bool enable )
}
}
void LLMenuGL::setItemVisible( const std::string& name, bool visible )
void LLMenuGL::setItemVisible(std::string_view name, bool visible )
{
item_list_t::iterator item_iter;
for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter)
@ -3277,7 +3277,7 @@ void LLMenuGL::setVisible(bool visible)
}
}
LLMenuGL* LLMenuGL::findChildMenuByName(const std::string& name, bool recurse) const
LLMenuGL* LLMenuGL::findChildMenuByName(std::string_view name, bool recurse) const
{
LLView* view = findChildView(name, recurse);
if (view)

View File

@ -456,7 +456,7 @@ public:
virtual bool hasAccelerator(const KEY &key, const MASK &mask) const;
virtual bool handleAcceleratorKey(KEY key, MASK mask);
LLMenuGL* findChildMenuByName(const std::string& name, bool recurse) const;
LLMenuGL* findChildMenuByName(std::string_view name, bool recurse) const;
bool clearHoverItem();
@ -479,12 +479,12 @@ public:
// setItemEnabled() - pass the name and the enable flag for a
// menu item. true will make sure it's enabled, false will disable
// it.
void setItemEnabled( const std::string& name, bool enable );
void setItemEnabled(std::string_view name, bool enable );
// propagate message to submenus
void setEnabledSubMenus(bool enable);
void setItemVisible( const std::string& name, bool visible);
void setItemVisible(std::string_view name, bool visible);
void setItemLabel(const std::string &name, const std::string &label);

View File

@ -1401,7 +1401,7 @@ S32 LLTabContainer::getIndexForPanel(LLPanel* panel)
return -1;
}
S32 LLTabContainer::getPanelIndexByTitle(const std::string& title)
S32 LLTabContainer::getPanelIndexByTitle(std::string_view title)
{
for (S32 index = 0 ; index < (S32)mTabList.size(); index++)
{
@ -1413,7 +1413,7 @@ S32 LLTabContainer::getPanelIndexByTitle(const std::string& title)
return -1;
}
LLPanel* LLTabContainer::getPanelByName(const std::string& name)
LLPanel* LLTabContainer::getPanelByName(std::string_view name)
{
for (S32 index = 0 ; index < (S32)mTabList.size(); index++)
{
@ -1637,7 +1637,7 @@ bool LLTabContainer::setTab(S32 which)
return is_visible;
}
bool LLTabContainer::selectTabByName(const std::string& name)
bool LLTabContainer::selectTabByName(std::string_view name)
{
LLPanel* panel = getPanelByName(name);
if (!panel)

View File

@ -190,8 +190,8 @@ public:
S32 getTabCount();
LLPanel* getPanelByIndex(S32 index);
S32 getIndexForPanel(LLPanel* panel);
S32 getPanelIndexByTitle(const std::string& title);
LLPanel* getPanelByName(const std::string& name);
S32 getPanelIndexByTitle(std::string_view title);
LLPanel* getPanelByName(std::string_view name);
S32 getTotalTabWidth() const;
void setCurrentTabName(const std::string& name);
@ -201,7 +201,7 @@ public:
void selectPrevTab();
bool selectTabPanel( LLPanel* child );
bool selectTab(S32 which);
bool selectTabByName(const std::string& title);
bool selectTabByName(std::string_view title);
void setCurrentPanelIndex(S32 index) { mCurrentTabIdx = index; }
bool getTabPanelFlashing(LLPanel* child);

View File

@ -1910,7 +1910,7 @@ void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location)
void LLFloaterPreference::selectPanel(const LLSD& name)
{
LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");
LLPanel * panel = tab_containerp->getPanelByName(name);
LLPanel * panel = tab_containerp->getPanelByName(name.asStringRef());
if (NULL != panel)
{
tab_containerp->selectTabPanel(panel);