diff options
author | Rok Povsic <rok.povsic@gmail.com> | 2021-12-19 13:55:54 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-20 11:31:47 +0100 |
commit | d3a80b1a6e66ed1d142eea06fc873861c1497039 (patch) | |
tree | 27c3074bf876f3dbb9b45921012e2d3e213b7e44 /Userland/DevTools/Profiler | |
parent | 47a4737110743f21e97ef03c2db3828692ef5c22 (diff) | |
download | serenity-d3a80b1a6e66ed1d142eea06fc873861c1497039.zip |
Profiler: Extract the bar label String into a private method
Diffstat (limited to 'Userland/DevTools/Profiler')
-rw-r--r-- | Userland/DevTools/Profiler/FlameGraphView.cpp | 16 | ||||
-rw-r--r-- | Userland/DevTools/Profiler/FlameGraphView.h | 1 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Userland/DevTools/Profiler/FlameGraphView.cpp b/Userland/DevTools/Profiler/FlameGraphView.cpp index 76fcffeb9c..c2dcbdc36f 100644 --- a/Userland/DevTools/Profiler/FlameGraphView.cpp +++ b/Userland/DevTools/Profiler/FlameGraphView.cpp @@ -116,11 +116,7 @@ void FlameGraphView::paint_event(GUI::PaintEvent& event) painter.add_clip_rect(event.rect()); for (const auto& bar : m_bars) { - auto label_index = bar.index.sibling_at_column(m_text_column); - String label = "All"; - if (label_index.is_valid()) { - label = m_model.data(label_index).to_string(); - } + auto label = bar_label(bar); auto color = m_colors[label.hash() % m_colors.size()]; @@ -148,6 +144,16 @@ void FlameGraphView::paint_event(GUI::PaintEvent& event) } } +String FlameGraphView::bar_label(StackBar const& bar) const +{ + auto label_index = bar.index.sibling_at_column(m_text_column); + String label = "All"; + if (label_index.is_valid()) { + label = m_model.data(label_index).to_string(); + } + return label; +} + void FlameGraphView::layout_bars() { m_bars.clear(); diff --git a/Userland/DevTools/Profiler/FlameGraphView.h b/Userland/DevTools/Profiler/FlameGraphView.h index 881738cf20..cff5837def 100644 --- a/Userland/DevTools/Profiler/FlameGraphView.h +++ b/Userland/DevTools/Profiler/FlameGraphView.h @@ -45,6 +45,7 @@ private: bool selected; }; + String bar_label(StackBar const&) const; void layout_bars(); void layout_children(GUI::ModelIndex& parent, int depth, int left, int right, Vector<GUI::ModelIndex>& selected); |