From e834e77988fcf637ee0f3e4c5c0875e47044e324 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 1 Jul 2024 21:48:34 -0400 Subject: Reduce string temporaries from findChild and getChild --- indra/llui/llview.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indra/llui/llview.h') diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 3ce7243370..4a9bef158a 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -341,8 +341,8 @@ public: S32 getChildCount() const { return (S32)mChildList.size(); } template 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 tree_iterator_t; @@ -452,24 +452,24 @@ public: // static method handles NULL pointer too static std::string getPathname(const LLView*); - template T* findChild(const std::string& name, bool recurse = true) const + template T* findChild(std::string_view name, bool recurse = true) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast(child); return result; } - template T* getChild(const std::string& name, bool recurse = true) const; + template T* getChild(std::string_view name, bool recurse = true) const; - template T& getChildRef(const std::string& name, bool recurse = true) const + template T& getChildRef(std::string_view name, bool recurse = true) const { return *getChild(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 T* getDefaultWidget(const std::string& name) const + template T* getDefaultWidget(std::string_view name) const { LLView* widgetp = getDefaultWidgetContainer().findChildView(name); return dynamic_cast(widgetp); @@ -576,7 +576,7 @@ private: LLView* childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra, bool allow_mouse_block = true); template - 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() @@ -696,7 +696,7 @@ struct TypeValues : public LLInitParam::TypeValuesHelper T* LLView::getChild(const std::string& name, bool recurse) const +template T* LLView::getChild(std::string_view name, bool recurse) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast(child); @@ -731,7 +731,7 @@ template 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( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif //LL_LLVIEW_H -- cgit v1.2.3 From b0e30477e93bb16b0cf8c7b64aaee35cedf85ca8 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 1 Jul 2024 22:25:56 -0400 Subject: Use heterogeneous comparison for string_view map finds in LLControl and convert controlExists to string_view --- indra/llui/llview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llview.h') 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(); } -- cgit v1.2.3