diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index ac05a6b0faf64e7a318913cbb08ddcbf12be7509..96d1d9ff15d5f18c2986be638b8c23a86074bc93 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -36,7 +36,7 @@ static LLDefaultChildRegistry::Register<LLBadge> r("badge"); static const S32 BADGE_OFFSET_NOT_SPECIFIED = 0x7FFFFFFF; // Compiler optimization, generate extern template -template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, BOOL recurse) const; +template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, BOOL recurse) const; LLBadge::Params::Params() diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index 55f92e6e34ae05bb08d4a256aaee26a46820a347..4d2ab5b6c3f8412ead651c55d6d7c6ecc91d86cd 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -171,7 +171,7 @@ class LLBadge // Build time optimization, generate once in .cpp file #ifndef LLBADGE_CPP -extern template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, BOOL recurse) const; +extern template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, BOOL recurse) const; #endif #endif // LL_LLBADGE_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index e2fb5ddb2681209f57e56bc0a7a8182952604f5c..e97ac05af6005231b854689e2951b588fb758315 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -55,7 +55,7 @@ static LLDefaultChildRegistry::Register<LLButton> r("button"); // Compiler optimization, generate extern template template class LLButton* LLView::getChild<class LLButton>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; // globals loaded from settings.xml S32 LLBUTTON_H_PAD = 4; diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 4dfea852bb72da0db068a3e26d249b1ac4623b3a..22517b5b4a6fccd111caac2b2b76e500d81cc53a 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -395,7 +395,7 @@ class LLButton // Build time optimization, generate once in .cpp file #ifndef LLBUTTON_CPP extern template class LLButton* LLView::getChild<class LLButton>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif // LL_LLBUTTON_H diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index 6a51c4240b5864ae3fa5bd9503e054e9402b0e32..b1ab2857186131e4ce78492f1eab9a7fb21ebe7d 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -45,7 +45,7 @@ static LLDefaultChildRegistry::Register<LLCheckBoxCtrl> r("check_box"); // Compiler optimization, generate extern template template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; void LLCheckBoxCtrl::WordWrap::declareValues() { diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h index eb5bd5b6da5c26851d33ed6463ce1381f805213b..2f0c4ade6423dfa62474a301bea84cf5c0133fbc 100644 --- a/indra/llui/llcheckboxctrl.h +++ b/indra/llui/llcheckboxctrl.h @@ -151,7 +151,7 @@ class LLCheckBoxCtrl // Build time optimization, generate once in .cpp file #ifndef LLCHECKBOXCTRL_CPP extern template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif // LL_LLCHECKBOXCTRL_H diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp index 7525b8cab3a7506fd7a39d8a91ac087a1959bd53..741ed2ae0e9ebb4a807ece6a2c97be911fe6b6c7 100644 --- a/indra/llui/llfloaterreglistener.cpp +++ b/indra/llui/llfloaterreglistener.cpp @@ -131,7 +131,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const { // Here 'floater' points to an LLFloater instance with the specified // name and key which isShown(). - LLButton* button = floater->findChild<LLButton>(event["button"]); + LLButton* button = floater->findChild<LLButton>(event["button"].asString()); if (! LLButton::isAvailable(button)) { reply["type"] = "LLButton"; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 63afd42ef15b3ce95b1a8593b0d7798adfcc71ae..06f4f24fe0d4eeb62393ac0bec0ada415e9121c4 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -74,7 +74,7 @@ static LLDefaultChildRegistry::Register<LLLineEditor> r1("line_editor"); // Compiler optimization, generate extern template template class LLLineEditor* LLView::getChild<class LLLineEditor>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; // // Member functions diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 902e52519b8a55781747b00756e1112ab1e1c1f9..542cc0fddfbab45e7fb1525df33c21edf649dad5 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -451,7 +451,7 @@ class LLLineEditor // Build time optimization, generate once in .cpp file #ifndef LLLINEEDITOR_CPP extern template class LLLineEditor* LLView::getChild<class LLLineEditor>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif // LL_LINEEDITOR_ diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 0ae8bf6d895439bd1468bbea7d10171bef95258b..629bd876d7640c022fb49de8dbd4540a5adfdf5b 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -971,7 +971,7 @@ LLMenuItemBranchGL::~LLMenuItemBranchGL() // virtual -LLView* LLMenuItemBranchGL::getChildView(const std::string& name, BOOL recurse) const +LLView* LLMenuItemBranchGL::getChildView(std::string_view name, BOOL recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -988,7 +988,7 @@ LLView* LLMenuItemBranchGL::getChildView(const std::string& name, BOOL recurse) return LLView::getChildView(name, recurse); } -LLView* LLMenuItemBranchGL::findChildView(const std::string& name, BOOL recurse) const +LLView* LLMenuItemBranchGL::findChildView(std::string_view name, BOOL recurse) const { LLMenuGL* branch = getBranch(); if (branch) diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index e3378aad6180407ea2c41db1249f66ea4b47fd7a..7bea51372bca0c594728a0c9e553c5f816540b37 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -664,8 +664,8 @@ class LLMenuItemBranchGL : public LLMenuItemGL virtual void openMenu(); - virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE) const; - virtual LLView* findChildView(const std::string& name, BOOL recurse = TRUE) const; + LLView* getChildView(std::string_view name, BOOL recurse = TRUE) const final; + LLView* findChildView(std::string_view name, BOOL recurse = TRUE) const final; private: LLHandle<LLView> mBranchHandle; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 817ac559280eac391ef6dd20eaee9b6bdbe1f812..9c4345d865a4fce247920f27446052e9c4602fb3 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -55,7 +55,7 @@ LLPanel::factory_stack_t LLPanel::sFactoryStack; // Compiler optimization, generate extern template template class LLPanel* LLView::getChild<class LLPanel>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; LLPanel::LocalizedString::LocalizedString() : name("name"), @@ -275,7 +275,7 @@ void LLPanel::setDefaultBtn(LLButton* btn) } } -void LLPanel::setDefaultBtn(const std::string& id) +void LLPanel::setDefaultBtn(std::string_view id) { LLButton *button = getChild<LLButton>(id); if (button) @@ -461,7 +461,7 @@ void LLPanel::initFromParams(const LLPanel::Params& p) it != p.strings.end(); ++it) { - mUIStrings[it->name] = it->value; + mUIStrings[it->name()] = it->value; } setLabel(p.label()); @@ -591,12 +591,12 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return TRUE; } -bool LLPanel::hasString(const std::string& name) +bool LLPanel::hasString(std::string_view name) { return mUIStrings.find(name) != mUIStrings.end(); } -std::string LLPanel::getString(const std::string& name, const LLStringUtil::format_map_t& args) const +std::string LLPanel::getString(std::string_view name, const LLStringUtil::format_map_t& args) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -606,7 +606,7 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form formatted_string.setArgList(args); return formatted_string.getString(); } - std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate + std::string err_str = absl::StrCat("Failed to find string ", name, " in panel ", getName()); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -618,14 +618,14 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form return LLStringUtil::null; } -std::string LLPanel::getString(const std::string& name) const +std::string LLPanel::getString(std::string_view name) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) { return found_it->second; } - std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate + std::string err_str = absl::StrCat("Failed to find string ", name, " in panel ", getName()); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -634,11 +634,11 @@ std::string LLPanel::getString(const std::string& name) const { LL_WARNS() << err_str << LL_ENDL; } - return LLStringUtil::null; + return {}; } -void LLPanel::childSetVisible(const std::string& id, bool visible) +void LLPanel::childSetVisible(std::string_view id, bool visible) { LLView* child = findChild<LLView>(id); if (child) @@ -647,7 +647,7 @@ void LLPanel::childSetVisible(const std::string& id, bool visible) } } -void LLPanel::childSetEnabled(const std::string& id, bool enabled) +void LLPanel::childSetEnabled(std::string_view id, bool enabled) { LLView* child = findChild<LLView>(id); if (child) @@ -656,7 +656,7 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled) } } -void LLPanel::childSetFocus(const std::string& id, BOOL focus) +void LLPanel::childSetFocus(std::string_view id, BOOL focus) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -665,7 +665,7 @@ void LLPanel::childSetFocus(const std::string& id, BOOL focus) } } -BOOL LLPanel::childHasFocus(const std::string& id) +BOOL LLPanel::childHasFocus(std::string_view id) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -682,7 +682,7 @@ BOOL LLPanel::childHasFocus(const std::string& id) // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. -void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data) +void LLPanel::childSetCommitCallback(std::string_view id, boost::function<void (LLUICtrl*,void*)> cb, void* data) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -691,7 +691,7 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void } } -void LLPanel::childSetColor(const std::string& id, const LLColor4& color) +void LLPanel::childSetColor(std::string_view id, const LLColor4& color) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -700,7 +700,7 @@ void LLPanel::childSetColor(const std::string& id, const LLColor4& color) } } -LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const +LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -710,7 +710,7 @@ LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& return NULL; } -LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const +LLCtrlListInterface* LLPanel::childGetListInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -720,7 +720,7 @@ LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const return NULL; } -LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) const +LLCtrlScrollInterface* LLPanel::childGetScrollInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -730,7 +730,7 @@ LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) c return NULL; } -void LLPanel::childSetValue(const std::string& id, LLSD value) +void LLPanel::childSetValue(std::string_view id, LLSD value) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -739,7 +739,7 @@ void LLPanel::childSetValue(const std::string& id, LLSD value) } } -LLSD LLPanel::childGetValue(const std::string& id) const +LLSD LLPanel::childGetValue(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -750,7 +750,7 @@ LLSD LLPanel::childGetValue(const std::string& id) const return LLSD(); } -BOOL LLPanel::childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +BOOL LLPanel::childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -760,7 +760,7 @@ BOOL LLPanel::childSetTextArg(const std::string& id, const std::string& key, con return FALSE; } -BOOL LLPanel::childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +BOOL LLPanel::childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLView* child = findChild<LLView>(id); if (child) @@ -770,7 +770,7 @@ BOOL LLPanel::childSetLabelArg(const std::string& id, const std::string& key, co return FALSE; } -void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function) +void LLPanel::childSetAction(std::string_view id, const commit_signal_t::slot_type& function) { LLButton* button = findChild<LLButton>(id); if (button) @@ -779,7 +779,7 @@ void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_ } } -void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value) +void LLPanel::childSetAction(std::string_view id, boost::function<void(void*)> function, void* value) { LLButton* button = findChild<LLButton>(id); if (button) diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 0a77f8e6299e8ba711fd04b3cfe77aecd42202f9..e458a0cdba33a9d21e6b0ce50faaabbd37ff207d 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -148,11 +148,11 @@ class LLPanel : public LLUICtrl, public LLBadgeHolder void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } BOOL isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); - void setDefaultBtn(const std::string& id); + void setDefaultBtn(std::string_view id); void updateDefaultBtn(); void setLabel(const LLStringExplicit& label) { mLabel = label; } std::string getLabel() const { return mLabel; } - void setHelpTopic(const std::string& help_topic) { mHelpTopic = help_topic; } + void setHelpTopic(std::string help_topic) { mHelpTopic = std::move(help_topic); } std::string getHelpTopic() const { return mHelpTopic; } void setCtrlsEnabled(BOOL b); @@ -168,54 +168,54 @@ class LLPanel : public LLUICtrl, public LLBadgeHolder void initFromParams(const Params& p); BOOL initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); - bool hasString(const std::string& name); - std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; - std::string getString(const std::string& name) const; + bool hasString(std::string_view name); + std::string getString(std::string_view name, const LLStringUtil::format_map_t& args) const; + std::string getString(std::string_view name) const; // ** Wrappers for setting child properties by name ** -TomY // WARNING: These are deprecated, please use getChild<T>("name")->doStuff() idiom instead // LLView - void childSetVisible(const std::string& name, bool visible); + void childSetVisible(std::string_view name, bool visible); - void childSetEnabled(const std::string& name, bool enabled); - void childEnable(const std::string& name) { childSetEnabled(name, true); } - void childDisable(const std::string& name) { childSetEnabled(name, false); }; + void childSetEnabled(std::string_view name, bool enabled); + void childEnable(std::string_view name) { childSetEnabled(name, true); } + void childDisable(std::string_view name) { childSetEnabled(name, false); }; // LLUICtrl - void childSetFocus(const std::string& id, BOOL focus = TRUE); - BOOL childHasFocus(const std::string& id); + void childSetFocus(std::string_view id, BOOL focus = TRUE); + BOOL childHasFocus(std::string_view id); // *TODO: Deprecate; for backwards compatability only: // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. - void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data); - void childSetColor(const std::string& id, const LLColor4& color); + void childSetCommitCallback(std::string_view id, boost::function<void (LLUICtrl*,void*)> cb, void* data); + void childSetColor(std::string_view id, const LLColor4& color); - LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; - LLCtrlListInterface* childGetListInterface(const std::string& id) const; - LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; + LLCtrlSelectionInterface* childGetSelectionInterface(std::string_view id) const; + LLCtrlListInterface* childGetListInterface(std::string_view id) const; + LLCtrlScrollInterface* childGetScrollInterface(std::string_view id) const; // This is the magic bullet for data-driven UI - void childSetValue(const std::string& id, LLSD value); - LLSD childGetValue(const std::string& id) const; + void childSetValue(std::string_view id, LLSD value); + LLSD childGetValue(std::string_view id) const; // For setting text / label replacement params, e.g. "Hello [NAME]" // Not implemented for all types, defaults to noop, returns FALSE if not applicaple - BOOL childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - BOOL childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + BOOL childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text); + BOOL childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text); // LLButton - void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value); - void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); + void childSetAction(std::string_view id, boost::function<void(void*)> function, void* value); + void childSetAction(std::string_view id, const commit_signal_t::slot_type& function); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); //call onOpen to let panel know when it's about to be shown or activated virtual void onOpen(const LLSD& key) {} - void setXMLFilename(std::string filename) { mXMLFilename = filename; }; + void setXMLFilename(std::string filename) { mXMLFilename = std::move(filename); }; std::string getXMLFilename() { return mXMLFilename; }; boost::signals2::connection setVisibleCallback( const commit_signal_t::slot_type& cb ); @@ -249,7 +249,7 @@ class LLPanel : public LLUICtrl, public LLBadgeHolder LLButton* mDefaultBtn; LLUIString mLabel; - typedef std::map<std::string, std::string> ui_string_map_t; + typedef absl::node_hash_map<std::string, std::string> ui_string_map_t; ui_string_map_t mUIStrings; @@ -258,7 +258,7 @@ class LLPanel : public LLUICtrl, public LLBadgeHolder // Build time optimization, generate once in .cpp file #ifndef LLPANEL_CPP extern template class LLPanel* LLView::getChild<class LLPanel>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif typedef boost::function<LLPanel* (void)> LLPanelClassCreatorFunc; @@ -271,12 +271,12 @@ class LLRegisterPanelClass final LLSINGLETON_EMPTY_CTOR(LLRegisterPanelClass); public: // register with either the provided builder, or the generic templated builder - void addPanelClass(const std::string& tag,LLPanelClassCreatorFunc func) + void addPanelClass(std::string tag, LLPanelClassCreatorFunc func) { - mPanelClassesNames[tag] = func; + mPanelClassesNames.insert_or_assign(std::move(tag), std::move(func)); } - LLPanel* createPanelClass(const std::string& tag) + LLPanel* createPanelClass(const std::string_view tag) { param_name_map_t::iterator iT = mPanelClassesNames.find(tag); if(iT == mPanelClassesNames.end()) @@ -291,7 +291,7 @@ class LLRegisterPanelClass final } private: - typedef std::map< std::string, LLPanelClassCreatorFunc> param_name_map_t; + typedef std::map< std::string, LLPanelClassCreatorFunc, std::less<>> param_name_map_t; param_name_map_t mPanelClassesNames; }; diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 3b166f261dcb4c63474a9ca6c659de1564415cb6..44f33801fc32e3fd6d7f38623174173a5977a329 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -312,7 +312,7 @@ void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent) } //virtual -LLView* LLTabContainer::getChildView(const std::string& name, BOOL recurse) const +LLView* LLTabContainer::getChildView(std::string_view name, BOOL recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -340,7 +340,7 @@ LLView* LLTabContainer::getChildView(const std::string& name, BOOL recurse) cons } //virtual -LLView* LLTabContainer::findChildView(const std::string& name, BOOL recurse) const +LLView* LLTabContainer::findChildView(std::string_view name, BOOL recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index 8f8cedb1b967b390beaa7465b7e59c551428e978..94d7b02a64b910ffde2cfcb064677a9e9448171f 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -147,8 +147,8 @@ class LLTabContainer : public LLPanel /*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, EAcceptance* accept, std::string& tooltip); - /*virtual*/ LLView* getChildView(const std::string& name, BOOL recurse = TRUE) const; - /*virtual*/ LLView* findChildView(const std::string& name, BOOL recurse = TRUE) const; + /*virtual*/ LLView* getChildView(std::string_view name, BOOL recurse = TRUE) const final; + /*virtual*/ LLView* findChildView(std::string_view name, BOOL recurse = TRUE) const final; /*virtual*/ void initFromParams(const LLPanel::Params& p); /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); /*virtual*/ BOOL postBuild(); diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 0afd32f33279bde6fbbe67ea9d2e21e39951eaec..3ceeb23dd3a0623648d9df2362ecce7a34c534e8 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -39,7 +39,7 @@ static LLDefaultChildRegistry::Register<LLTextBox> r("text"); // Compiler optimization, generate extern template template class LLTextBox* LLView::getChild<class LLTextBox>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; LLTextBox::LLTextBox(const LLTextBox::Params& p) : LLTextBase(p), diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index 061d2dd23db285388d2b2584be123cf402f4f1e1..dd7a3aff39af76c328191aa6d83ca015d5fb55e5 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -81,7 +81,7 @@ class LLTextBox : // Build time optimization, generate once in .cpp file #ifndef LLTEXTBOX_CPP extern template class LLTextBox* LLView::getChild<class LLTextBox>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index dc3353f42cef783aa489256a2b21540325b221a1..a09192dbb6bc643886822714aa466a5f1fd51403 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -70,7 +70,7 @@ static LLDefaultChildRegistry::Register<LLTextEditor> r("simple_text_editor"); // Compiler optimization, generate extern template template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; // // Constants diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index 5e9e1a27cdab78a26eb1ec278b0701422af3b0ae..c996658d93fdbf9a2c5d26c488b90544f1fe8229 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -335,7 +335,7 @@ class LLTextEditor : // Build time optimization, generate once in .cpp file #ifndef LLTEXTEDITOR_CPP extern template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif // LL_TEXTEDITOR_H diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 31107bf4752f4a420a6d2f939835bc32e9432e54..1d9f0b75cdea999605fd27287cc93a0251b5e703 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -43,7 +43,7 @@ F32 LLUICtrl::sInactiveControlTransparency = 1.0f; // Compiler optimization, generate extern template template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; LLUICtrl::CallbackParam::CallbackParam() : name("name"), @@ -135,7 +135,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.enabled_controls.enabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.enabled); + LLControlVariable* control = findControl(p.enabled_controls.enabled()); if (control) { setEnabledControlVariable(control); @@ -149,7 +149,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if(p.enabled_controls.disabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.disabled); + LLControlVariable* control = findControl(p.enabled_controls.disabled()); if (control) { setDisabledControlVariable(control); @@ -166,7 +166,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.controls_visibility.visible.isChosen()) { - LLControlVariable* control = findControl(p.controls_visibility.visible); + LLControlVariable* control = findControl(p.controls_visibility.visible()); if (control) { setMakeVisibleControlVariable(control); @@ -180,7 +180,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if (p.controls_visibility.invisible.isChosen()) { - LLControlVariable* control = findControl(p.controls_visibility.invisible); + LLControlVariable* control = findControl(p.controls_visibility.invisible()); if (control) { setMakeInvisibleControlVariable(control); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 3cca281f1ca1168018101a0a24e2a9fbf6b70141..cba737eb81a5091d85cb0df878c390ccc8fac1b0 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -328,7 +328,7 @@ class LLUICtrl // Build time optimization, generate once in .cpp file #ifndef LLUICTRL_CPP extern template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif // LL_LLUICTRL_H diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 4e1b98fc7e37170a9bfc371ee638ad02f8ef3766..2574f6dcbc1b9a2532b28c6087b019a11ec73398 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -84,7 +84,7 @@ BOOL LLView::sIsDrawing = FALSE; // Compiler optimization, generate extern template template class LLView* LLView::getChild<class LLView>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; static LLDefaultChildRegistry::Register<LLView> r("view"); @@ -718,7 +718,7 @@ void LLView::logMouseEvent() } template <typename METHOD, typename CHARTYPE> -LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, +LLView* LLView::childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask) { if ( getVisible() && getEnabled() ) @@ -1574,7 +1574,7 @@ BOOL LLView::hasAncestor(const LLView* parentp) const //----------------------------------------------------------------------------- -BOOL LLView::childHasKeyboardFocus( const std::string& childname ) const +BOOL LLView::childHasKeyboardFocus(std::string_view childname) const { LLView *focus = dynamic_cast<LLView *>(gFocusMgr.getKeyboardFocus()); @@ -1593,7 +1593,7 @@ BOOL LLView::childHasKeyboardFocus( const std::string& childname ) const //----------------------------------------------------------------------------- -BOOL LLView::hasChild(const std::string& childname, BOOL recurse) const +BOOL LLView::hasChild(std::string_view childname, BOOL recurse) const { return findChildView(childname, recurse) != NULL; } @@ -1601,14 +1601,14 @@ BOOL LLView::hasChild(const std::string& childname, BOOL recurse) const //----------------------------------------------------------------------------- // getChildView() //----------------------------------------------------------------------------- -LLView* LLView::getChildView(const std::string& name, BOOL recurse) const +LLView* LLView::getChildView(std::string_view name, BOOL recurse) const { return getChild<LLView>(name, recurse); } static LLTrace::BlockTimerStatHandle FTM_FIND_VIEWS("Find Widgets"); -LLView* LLView::findChildView(const std::string& name, BOOL recurse) const +LLView* LLView::findChildView(std::string_view name, BOOL recurse) const { LL_RECORD_BLOCK_TIME(FTM_FIND_VIEWS); //richard: should we allow empty names? @@ -2265,13 +2265,13 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna //----------------------------------------------------------------------------- -LLControlVariable *LLView::findControl(const std::string& name) +LLControlVariable *LLView::findControl(std::string_view name) { // parse the name to locate which group it belongs to - std::size_t key_pos= name.find("."); - if(key_pos!= std::string::npos ) + std::size_t key_pos = name.find('.'); + if(key_pos != std::string::npos ) { - std::string control_group_key = name.substr(0, key_pos); + std::string control_group_key(name.substr(0, key_pos)); LLControlVariable* control; // check if it's in the control group that name indicated if(LLUI::getInstance()->mSettingGroups[control_group_key]) diff --git a/indra/llui/llview.h b/indra/llui/llview.h index c60dcf3344f204e442c10bb7e42310fda2375a45..499df896a64bbcf4eb7afdc3eb0e86af5956c813 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -238,7 +238,7 @@ class LLView void setFollowsAll() { mReshapeFlags |= FOLLOWS_ALL; } void setSoundFlags(U8 flags) { mSoundFlags = flags; } - void setName(std::string name) { mName = name; } + void setName(std::string name) { mName = std::move(name); } void setUseBoundingRect( BOOL use_bounding_rect ); BOOL getUseBoundingRect() const; @@ -338,8 +338,8 @@ class LLView S32 getChildCount() const { return (S32)mChildList.size(); } template<class _Pr3> void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); } BOOL hasAncestor(const LLView* parentp) const; - BOOL hasChild(const std::string& childname, BOOL recurse = FALSE) const; - BOOL childHasKeyboardFocus( const std::string& childname ) const; + BOOL hasChild(std::string_view childname, BOOL recurse = FALSE) const; + BOOL childHasKeyboardFocus(std::string_view childname ) const; // these iterators are used for collapsing various tree traversals into for loops typedef LLTreeDFSIter<LLView, child_list_const_iter_t> tree_iterator_t; @@ -412,7 +412,7 @@ class LLView void screenRectToLocal( const LLRect& screen, LLRect* local ) const; void localRectToScreen( const LLRect& local, LLRect* screen ) const; - LLControlVariable *findControl(const std::string& name); + LLControlVariable *findControl(std::string_view name); const child_list_t* getChildList() const { return &mChildList; } child_list_const_iter_t beginChild() const { return mChildList.begin(); } @@ -448,24 +448,24 @@ class LLView // static method handles NULL pointer too static std::string getPathname(const LLView*); - template <class T> T* findChild(const std::string& name, BOOL recurse = TRUE) const + template <class T> T* findChild(std::string_view name, BOOL recurse = TRUE) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast<T*>(child); return result; } - template <class T> T* getChild(const std::string& name, BOOL recurse = TRUE) const; + template <class T> T* getChild(std::string_view name, BOOL recurse = TRUE) const; - template <class T> T& getChildRef(const std::string& name, BOOL recurse = TRUE) const + template <class T> T& getChildRef(std::string_view name, BOOL recurse = TRUE) const { return *getChild<T>(name, recurse); } - virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE) const; - virtual LLView* findChildView(const std::string& name, BOOL recurse = TRUE) const; + virtual LLView* getChildView(std::string_view name, BOOL recurse = TRUE) const; + virtual LLView* findChildView(std::string_view name, BOOL recurse = TRUE) const; - template <class T> T* getDefaultWidget(const std::string& name) const + template <class T> T* getDefaultWidget(std::string_view name) const { LLView* widgetp = getDefaultWidgetContainer().findChildView(name); return dynamic_cast<T*>(widgetp); @@ -572,7 +572,7 @@ class LLView LLView* childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra, bool allow_mouse_block = true); template <typename METHOD, typename CHARTYPE> - LLView* childrenHandleCharEvent(const std::string& desc, const METHOD& method, + LLView* childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask); // adapter to blur distinction between handleKey() and handleUnicodeChar() @@ -686,7 +686,7 @@ struct TypeValues<LLView::EOrientation> : public LLInitParam::TypeValuesHelper<L }; } -template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) const +template <class T> T* LLView::getChild(std::string_view name, BOOL recurse) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast<T*>(child); @@ -700,7 +700,7 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) co result = getDefaultWidget<T>(name); if (!result) { - result = LLUICtrlFactory::getDefaultWidget<T>(name); + result = LLUICtrlFactory::getDefaultWidget<T>(std::string(name)); if (result) { @@ -725,7 +725,7 @@ template <class T> T* LLView::getChild(const std::string& name, BOOL recurse) co // require explicit specialization. See llbutton.cpp for an example. #ifndef LLVIEW_CPP extern template class LLView* LLView::getChild<class LLView>( - const std::string& name, BOOL recurse) const; + std::string_view name, BOOL recurse) const; #endif #endif //LL_LLVIEW_H diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index e22cc1846133c5eaf0a5e0e11d5984d7ee1bd148..82e26499ee82420bb16cf19b177948cc9233335e 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -2305,12 +2305,12 @@ BOOL LLIncomingCallDialog::postBuild() if (gAgent.getGroupData(session_id, data)) { args["[GROUP]"] = data.mName; - call_type = getString(mPayload["notify_box_type"], args); + call_type = getString(mPayload["notify_box_type"].asStringRef(), args); } } else { - call_type = getString(mPayload["notify_box_type"]); + call_type = getString(mPayload["notify_box_type"].asStringRef()); }