Explorar o código

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. :^)
Andreas Kling %!s(int64=4) %!d(string=hai) anos
pai
achega
6387f65f87
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      Userland/Libraries/LibGUI/HeaderView.cpp

+ 4 - 2
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);
 }