diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-01-11 16:36:27 -0500 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-01-11 16:36:27 -0500 |
commit | 8f4c2a59db47283e1edb8ae7f6dee4466b95d1e9 (patch) | |
tree | a7c424eac11ce6eea55c6041e205ef09cb8c541f | |
parent | 1d9591afbe5946f0e3a75aea917097f6a08d8ce5 (diff) |
For EXT-4068: [BSI] right click several times on an inventory item produces several second hang. Improved speed of panel finding by restricting search to only panels, saving time when inventory is very large
-rw-r--r-- | indra/newview/llsidetray.cpp | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 608165022f..d1236b948e 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -641,24 +641,60 @@ LLPanel* LLSideTray::showPanel (const std::string& panel_name, const LLSD& para return NULL; } -LLPanel* LLSideTray::getPanel (const std::string& panel_name) +// This is just LLView::findChildView specialized to restrict the search to LLPanels. +// Optimization for EXT-4068 to avoid searching down to the individual item level +// when inventories are large. +LLPanel *findChildPanel(LLPanel *panel, const std::string& name, bool recurse, S32& count) { - child_vector_const_iter_t child_it; - for ( child_it = mTabs.begin(); child_it != mTabs.end(); ++child_it) + for (LLView::child_list_const_iter_t child_it = panel->beginChild(); + child_it != panel->endChild(); ++child_it) { - LLView* view = (*child_it)->findChildView(panel_name,true); - if(view) + count++; + LLPanel *child_panel = dynamic_cast<LLPanel*>(*child_it); + if (!child_panel) + continue; + if (child_panel->getName() == name) + return child_panel; + } + if (recurse) + { + for (LLView::child_list_const_iter_t child_it = panel->beginChild(); + child_it != panel->endChild(); ++child_it) { - LLPanel* panel = dynamic_cast<LLPanel*>(view); - if(panel) + count++; + LLPanel *child_panel = dynamic_cast<LLPanel*>(*child_it); + if (!child_panel) + continue; + LLPanel *found_panel = findChildPanel(child_panel,name,recurse,count); + if (found_panel) { - return panel; + return found_panel; } } } return NULL; } +LLPanel* LLSideTray::getPanel(const std::string& panel_name) +{ + static S32 max_count = 0; + S32 count = 0; + for ( child_vector_const_iter_t child_it = mTabs.begin(); child_it != mTabs.end(); ++child_it) + { + LLPanel *panel = findChildPanel(*child_it,panel_name,true,count); + if (count > max_count) + { + max_count = count; + llwarns << "max_count " << max_count << llendl; + } + if(panel) + { + return panel; + } + } + return NULL; +} + LLPanel* LLSideTray::getActivePanel() { if (mActiveTab && !mCollapsed) |