diff options
author | Rye Mutt <rye@alchemyviewer.org> | 2024-07-01 22:25:56 -0400 |
---|---|---|
committer | Rye Mutt <rye@alchemyviewer.org> | 2024-07-01 22:25:56 -0400 |
commit | b0e30477e93bb16b0cf8c7b64aaee35cedf85ca8 (patch) | |
tree | d8e0c8eca6f078395d0bc581925f589adc67d895 /indra | |
parent | 49d60e0ded52c095c834e9ca134b67282728b389 (diff) |
Use heterogeneous comparison for string_view map finds in LLControl and convert controlExists to string_view
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llstl.h | 6 | ||||
-rw-r--r-- | indra/llui/llnotifications.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llui.h | 4 | ||||
-rw-r--r-- | indra/llui/lluictrl.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 14 | ||||
-rw-r--r-- | indra/llui/llview.h | 2 | ||||
-rw-r--r-- | indra/llxml/llcontrol.cpp | 4 | ||||
-rw-r--r-- | indra/llxml/llcontrol.h | 4 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 2 |
10 files changed, 25 insertions, 23 deletions
diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index 1b52d94258..e3999cbdaa 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -226,11 +226,11 @@ void delete_and_clear_array(T*& ptr) // foo[2] = "hello"; // const char* bar = get_ptr_in_map(foo, 2); // bar -> "hello" // const char* baz = get_ptr_in_map(foo, 3); // baz == NULL -template <typename K, typename T> -inline T* get_ptr_in_map(const std::map<K,T*>& inmap, const K& key) +template <typename T> +inline typename T::mapped_type get_ptr_in_map(const T& inmap, typename T::key_type const& key) { // Typedef here avoids warnings because of new c++ naming rules. - typedef typename std::map<K,T*>::const_iterator map_iter; + typedef T::const_iterator map_iter; map_iter iter = inmap.find(key); if(iter == inmap.end()) { diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index bee7d5bb3f..825956227f 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -439,7 +439,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundName("") { if (p.sound.isProvided() - && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound)) + && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound())) { mSoundName = p.sound; } diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index f5c55a3d37..448c730688 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -367,7 +367,7 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } -LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname) +LLControlGroup& LLUI::getControlControlGroup (std::string_view controlname) { for (settings_map_t::iterator itor = mSettingGroups.begin(); itor != mSettingGroups.end(); ++itor) diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 373a358544..f33b43f599 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -115,7 +115,7 @@ typedef void (*LLUIAudioCallback)(const LLUUID& uuid); class LLUI : public LLParamSingleton<LLUI> { public: - typedef std::map<std::string, LLControlGroup*> settings_map_t; + typedef std::map<std::string, LLControlGroup*, std::less<> > settings_map_t; private: LLSINGLETON(LLUI , const settings_map_t &settings, @@ -295,7 +295,7 @@ public: void screenRectToGL(const LLRect& screen, LLRect *gl); void glRectToScreen(const LLRect& gl, LLRect *screen); // Returns the control group containing the control name, or the default group - LLControlGroup& getControlControlGroup (const std::string& controlname); + LLControlGroup& getControlControlGroup (std::string_view controlname); F32 getMouseIdleTime() { return mMouseIdleTimer.getElapsedTimeF32(); } void resetMouseIdleTimer() { mMouseIdleTimer.reset(); } LLWindow* getWindow() { return mWindow; } diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index d1011edcf7..cb86a79407 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -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/llview.cpp b/indra/llui/llview.cpp index ab03a7a9a8..7d6c937b85 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -2312,18 +2312,20 @@ 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) { + auto uiInst = LLUI::getInstance(); // parse the name to locate which group it belongs to std::size_t key_pos= name.find("."); - if(key_pos!= std::string::npos ) + if(key_pos != std::string_view::npos ) { - std::string control_group_key = name.substr(0, key_pos); + std::string_view 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]) + auto it = uiInst->mSettingGroups.find(control_group_key); + if(it != uiInst->mSettingGroups.end() && it->second) { - control = LLUI::getInstance()->mSettingGroups[control_group_key]->getControl(name); + control = it->second->getControl(name); if (control) { return control; @@ -2331,7 +2333,7 @@ LLControlVariable *LLView::findControl(const std::string& name) } } - LLControlGroup& control_group = LLUI::getInstance()->getControlControlGroup(name); + LLControlGroup& control_group = uiInst->getControlControlGroup(name); return control_group.getControl(name); } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 4a9bef158a..710ec3d05e 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -416,7 +416,7 @@ public: 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(); } diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 82e07e03c9..bb590ebd76 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -348,7 +348,7 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(std::string_view name) incrCount(name); } - ctrl_name_table_t::iterator iter = mNameTable.find(name.data()); + ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second; } @@ -657,7 +657,7 @@ LLSD LLControlGroup::asLLSD(bool diffs_only) return result; } -bool LLControlGroup::controlExists(const std::string& name) +bool LLControlGroup::controlExists(std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter != mNameTable.end(); diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 1b04729a82..344352e980 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -189,7 +189,7 @@ class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string> LOG_CLASS(LLControlGroup); protected: - typedef std::map<std::string, LLControlVariablePtr > ctrl_name_table_t; + typedef std::map<std::string, LLControlVariablePtr, std::less<> > ctrl_name_table_t; ctrl_name_table_t mNameTable; static const std::string mTypeString[TYPE_COUNT]; @@ -295,7 +295,7 @@ public: } } - bool controlExists(const std::string& name); + bool controlExists(std::string_view name); // Returns number of controls loaded, 0 if failed // If require_declaration is false, will auto-declare controls it finds diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 85ede793e2..51099a480d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2393,7 +2393,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string full_settings_path; if (file.file_name_setting.isProvided() - && gSavedSettings.controlExists(file.file_name_setting)) + && gSavedSettings.controlExists(file.file_name_setting())) { // try to find filename stored in file_name_setting control full_settings_path = gSavedSettings.getString(file.file_name_setting()); |