mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 18:12:22 +00:00
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:
parent
ada84d6aaf
commit
59ceddf917
@ -614,6 +614,7 @@ public:
|
||||
{
|
||||
delete item;
|
||||
}
|
||||
items_.clear();
|
||||
order_dirty_ = true;
|
||||
selected_item_count_ = 0;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user