From 6387f65f87400e5fb03bcbe86ecd0f54ba794aa0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 14 May 2021 10:25:42 +0200 Subject: 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. :^) --- Userland/Libraries/LibGUI/HeaderView.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries') 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(section) >= m_section_data.size()) - m_section_data.resize(section + 1); + VERIFY(model()); + if (static_cast(section) >= m_section_data.size()) { + m_section_data.resize(section_count()); + } return m_section_data.at(section); } -- cgit v1.2.3