LibGUI: Resize GUI::HeaderView section vector to final size immediately

When computing row & column sizes in AbstractTableView, it iterates
across both axes starting from 0.

This caused us to grow the corresponding HeaderView's internal section
vector by 1 entry for each step, leading to Vector::resize() thrashing.

Since we already know the final size, just resize to that immediately,
and the thrashing goes away.

This gives a huge speedup when loading large files into Profiler. :^)
This commit is contained in:
Andreas Kling 2021-05-14 10:25:42 +02:00
parent c63761a341
commit 6387f65f87
Notes: sideshowbarker 2024-07-18 18:10:44 +09:00

View file

@ -54,8 +54,10 @@ int HeaderView::section_size(int section) const
HeaderView::SectionData& HeaderView::section_data(int section) const
{
if (static_cast<size_t>(section) >= m_section_data.size())
m_section_data.resize(section + 1);
VERIFY(model());
if (static_cast<size_t>(section) >= m_section_data.size()) {
m_section_data.resize(section_count());
}
return m_section_data.at(section);
}