Skip to content

Commit bc4492d

Browse files
committed
#5046 Remove redundant updates in outfit list #1
1 parent d4bee6b commit bc4492d

File tree

4 files changed

+51
-10
lines changed

4 files changed

+51
-10
lines changed

indra/llui/llflatlistview.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ bool LLFlatListView::postBuild()
537537

538538
void LLFlatListView::rearrangeItems()
539539
{
540+
LL_PROFILE_ZONE_SCOPED;
540541
static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
541542

542543
setNoItemsCommentVisible(0==size());
@@ -1132,6 +1133,7 @@ bool LLFlatListView::removeItemPair(item_pair_t* item_pair, bool rearrange)
11321133

11331134
void LLFlatListView::notifyParentItemsRectChanged()
11341135
{
1136+
LL_PROFILE_ZONE_SCOPED;
11351137
S32 comment_height = 0;
11361138

11371139
// take into account comment text height if exists
@@ -1401,7 +1403,7 @@ bool LLFlatListViewEx::updateItemVisibility(LLPanel* item, const LLSD &action)
14011403
return false;
14021404
}
14031405

1404-
void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent)
1406+
bool LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent)
14051407
{
14061408
std::string cur_filter = mFilterSubString;
14071409
LLStringUtil::toUpper(cur_filter);
@@ -1426,7 +1428,9 @@ void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent)
14261428
{
14271429
rearrangeItems();
14281430
notifyParentItemsRectChanged();
1431+
return true;
14291432
}
1433+
return false;
14301434
}
14311435

14321436
bool LLFlatListViewEx::hasMatchedItems()

indra/llui/llflatlistview.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,9 @@ class LLFlatListViewEx : public LLFlatListView
499499
/**
500500
* Filters the list, rearranges and notifies parent about shape changes.
501501
* Derived classes may want to overload rearrangeItems() to exclude repeated separators after filtration.
502+
* Returns true in case of changes
502503
*/
503-
void filterItems(bool re_sort, bool notify_parent);
504+
bool filterItems(bool re_sort, bool notify_parent);
504505

505506
/**
506507
* Returns true if last call of filterItems() found at least one matching item

indra/newview/llinventoryitemslist.cpp

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p
5151
: LLFlatListViewEx(p)
5252
, mRefreshState(REFRESH_COMPLETE)
5353
, mForceRefresh(false)
54+
, mNeedsArrange(true)
5455
{
5556
// TODO: mCommitOnSelectionChange is set to "false" in LLFlatListView
5657
// but reset to true in all derived classes. This settings might need to
@@ -218,8 +219,6 @@ void LLInventoryItemsList::refresh()
218219
mRefreshState = REFRESH_LIST_SORT;
219220
}
220221

221-
rearrangeItems();
222-
notifyParentItemsRectChanged();
223222
break;
224223
}
225224
case REFRESH_LIST_ERASE:
@@ -229,10 +228,21 @@ void LLInventoryItemsList::refresh()
229228
for (; mRemovedItems.end() != it; ++it)
230229
{
231230
// don't filter items right away
232-
removeItemByUUID(*it, false);
231+
removeItemByUUID(*it, false /*don't rearrange*/);
233232
}
234233
mRemovedItems.clear();
235-
mRefreshState = REFRESH_LIST_SORT; // fix visibility and arrange
234+
mRefreshState = REFRESH_LIST_SORT; // fix visibility
235+
236+
// Assume that visible items were removed.
237+
if (getVisible())
238+
{
239+
rearrangeItems();
240+
notifyParentItemsRectChanged();
241+
}
242+
else
243+
{
244+
mNeedsArrange = true;
245+
}
236246
break;
237247
}
238248
case REFRESH_LIST_APPEND:
@@ -275,18 +285,25 @@ void LLInventoryItemsList::refresh()
275285
LLSD action;
276286
action.with("match_filter", cur_filter);
277287

288+
bool new_visible_items = false;
278289
pairs_const_iterator_t pair_it = panel_list.begin();
279290
for (; pair_it != panel_list.end(); ++pair_it)
280291
{
281292
item_pair_t* item_pair = *pair_it;
282293
if (item_pair->first->getParent() != NULL)
283294
{
284-
updateItemVisibility(item_pair->first, action);
295+
new_visible_items |= updateItemVisibility(item_pair->first, action);
285296
}
286297
}
287298

288-
rearrangeItems();
289-
notifyParentItemsRectChanged();
299+
mNeedsArrange |= new_visible_items;
300+
if (mNeedsArrange && getVisible())
301+
{
302+
// show changes now
303+
rearrangeItems();
304+
notifyParentItemsRectChanged();
305+
mNeedsArrange = false;
306+
}
290307

291308
if (mAddedItems.size() > 0)
292309
{
@@ -304,16 +321,33 @@ void LLInventoryItemsList::refresh()
304321
{
305322
LL_PROFILE_ZONE_NAMED("items_refresh_sort");
306323
// Filter, sort, rearrange and notify parent about shape changes
307-
filterItems(true, true);
324+
if (filterItems(true, true))
325+
{
326+
mNeedsArrange = false; // just rearranged
327+
}
308328

309329
if (mAddedItems.size() == 0)
310330
{
331+
if (mNeedsArrange)
332+
{
333+
// Done, last chance to rearrange
334+
rearrangeItems();
335+
notifyParentItemsRectChanged();
336+
mNeedsArrange = false;
337+
}
311338
// After list building completed, select items that had been requested to select before list was build
312339
updateSelection();
313340
mRefreshState = REFRESH_COMPLETE;
314341
}
315342
else
316343
{
344+
if (mNeedsArrange && getVisible())
345+
{
346+
// show changes now
347+
rearrangeItems();
348+
notifyParentItemsRectChanged();
349+
mNeedsArrange = false;
350+
}
317351
mRefreshState = REFRESH_LIST_APPEND;
318352
}
319353
break;
@@ -347,6 +381,7 @@ void LLInventoryItemsList::computeDifference(
347381

348382
LLPanel* LLInventoryItemsList::createNewItem(LLViewerInventoryItem* item)
349383
{
384+
LL_PROFILE_ZONE_SCOPED;
350385
if (!item)
351386
{
352387
LL_WARNS() << "No inventory item. Couldn't create flat list item." << LL_ENDL;

indra/newview/llinventoryitemslist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class LLInventoryItemsList : public LLFlatListViewEx
117117
};
118118

119119
ERefreshStates mRefreshState;
120+
bool mNeedsArrange = true;
120121

121122
private:
122123
uuid_vec_t mIDs; // IDs of items that were added in refreshList().

0 commit comments

Comments
 (0)