improve listbox::clear() performance. (#982)

previously listbox::clear() removed all elements one by one.
This was quite ineffective since due to the listbox always-one-element-selected behviour this required calculating which is the next element in this list in the current order. Which then again requires resorting of the whole list since due to the list content change (removal) the order cache is cleared.

this could also fix https://gna.org/bugs/?25504

this also fixed a bug in generator::clear()
This commit is contained in:
gfgtdf 2017-04-13 16:53:40 +02:00 committed by GitHub
parent ada84d6aaf
commit 59ceddf917
2 changed files with 3 additions and 3 deletions

View File

@ -614,6 +614,7 @@ public:
{
delete item;
}
items_.clear();
order_dirty_ = true;
selected_item_count_ = 0;
}

View File

@ -135,9 +135,8 @@ void listbox::remove_row(const unsigned row, unsigned count)
void listbox::clear()
{
// Due to the removing from the linked group, don't use
// generator_->clear() directly.
remove_row(0, 0);
generator_->clear();
update_content_size();
}
unsigned listbox::get_item_count() const