summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-14 10:25:42 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-14 10:32:44 +0200
commit6387f65f87400e5fb03bcbe86ecd0f54ba794aa0 (patch)
tree731692566c912c2ccf22ccf279b45d0b92ce5a1c /Userland/Libraries
parentc63761a3419781dc4e1b22f5586a2a908877463a (diff)
downloadserenity-6387f65f87400e5fb03bcbe86ecd0f54ba794aa0.zip
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. :^)
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/HeaderView.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/HeaderView.cpp b/Userland/Libraries/LibGUI/HeaderView.cpp
index 5ff11ce4a4..cb9fe2d202 100644
--- a/Userland/Libraries/LibGUI/HeaderView.cpp
+++ b/Userland/Libraries/LibGUI/HeaderView.cpp
@@ -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);
}