diff options
author | Ansariel <ansariel.hiller@phoenixviewer.com> | 2024-07-01 11:52:47 +0200 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-07-01 17:58:45 +0300 |
commit | b9740dfc6e72d34d135fb9dafe7eed250e4e8b6e (patch) | |
tree | 969383d16d4cf34a5500422b7fabab4f10ea4f82 | |
parent | 1142c2c79b79802c47720b10130bd194b2a8abf1 (diff) |
Fix loop scope issue and rework some strange-looking loops
-rw-r--r-- | indra/llui/llaccordionctrl.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llaccordionctrltab.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llflatlistview.cpp | 49 |
3 files changed, 22 insertions, 41 deletions
diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index 4682044d6e..06f7a20add 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -379,12 +379,10 @@ void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params) void LLAccordionCtrl::updateNoTabsHelpTextVisibility() { - bool visible_exists = false; - std::vector<LLAccordionCtrlTab*>::const_iterator it = mAccordionTabs.begin(); - const std::vector<LLAccordionCtrlTab*>::const_iterator it_end = mAccordionTabs.end(); - while (it < it_end) + bool visible_exists{ false }; + for (auto accordion_tab : mAccordionTabs) { - if ((*(it++))->getVisible()) + if (accordion_tab->getVisible()) { visible_exists = true; break; diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 6d58a2545c..ac66525030 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -602,15 +602,13 @@ void LLAccordionCtrlTab::setSelected(bool is_selected) LLView* LLAccordionCtrlTab::findContainerView() { - child_list_const_iter_t it = getChildList()->begin(), it_end = getChildList()->end(); - while (it != it_end) + for (auto child : *getChildList()) { - LLView* child = *(it++); if (DD_HEADER_NAME != child->getName() && child->getVisible()) return child; } - return NULL; + return nullptr; } void LLAccordionCtrlTab::selectOnFocusReceived() diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 1799968afb..53f39766c6 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -1250,17 +1250,15 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) detached_items.clear(); // Go through items and detach valid items, remove them from items panel // and add to detached_items. - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + for (auto item_pair : mItemPairs) { - LLPanel* pItem = (*iter)->first; + LLPanel* pItem = item_pair->first; if (1 == pItem->notify(action)) { - selectItemPair((*iter), false); + selectItemPair(item_pair, false); mItemsPanel->removeChild(pItem); - detached_items.push_back(pItem); + detached_items.emplace_back(pItem); } - iter++; } if (!detached_items.empty()) { @@ -1268,12 +1266,10 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) if (detached_items.size() == mItemPairs.size()) { // This way will be faster if all items were disconnected - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + for (auto item_pair : mItemPairs) { - (*iter)->first = NULL; - delete *iter; - iter++; + item_pair->first = nullptr; + delete item_pair; } mItemPairs.clear(); // Also set items panel height to zero. @@ -1286,26 +1282,16 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) } else { - std::vector<LLPanel*>::const_iterator - detached_iter = detached_items.begin(), - detached_iter_end = detached_items.end(); - while (detached_iter < detached_iter_end) + for (auto detached_item : detached_items) { - LLPanel* pDetachedItem = *detached_iter; - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + auto found_pos = std::find_if(mItemPairs.begin(), mItemPairs.end(), [detached_item](auto item_pair) { return item_pair->first == detached_item; }); + if (found_pos != mItemPairs.end()) { - item_pair_t* item_pair = *iter; - if (item_pair->first == pDetachedItem) - { - mItemPairs.erase(iter); - item_pair->first = NULL; - delete item_pair; - break; - } - iter++; + mItemPairs.erase(found_pos); + auto item_pair = *found_pos; + item_pair->first = nullptr; + delete item_pair; } - detached_iter++; } rearrangeItems(); } @@ -1412,11 +1398,10 @@ void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent) action.with("match_filter", cur_filter); mHasMatchedItems = false; - bool visibility_changed = false; - pairs_const_iterator_t iter = getItemPairs().begin(), iter_end = getItemPairs().end(); - while (iter != iter_end) + bool visibility_changed{ false }; + for (auto item_pair : getItemPairs()) { - LLPanel* pItem = (*(iter++))->first; + LLPanel* pItem = item_pair->first; visibility_changed |= updateItemVisibility(pItem, action); } |