hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/tools/perf/ui/browsers/hists.c
....@@ -407,11 +407,6 @@
407407 return container_of(ms, struct callchain_list, ms)->has_children;
408408 }
409409
410
-static bool hist_browser__he_selection_unfolded(struct hist_browser *browser)
411
-{
412
- return browser->he_selection ? browser->he_selection->unfolded : false;
413
-}
414
-
415410 static bool hist_browser__selection_unfolded(struct hist_browser *browser)
416411 {
417412 struct hist_entry *he = browser->he_selection;
....@@ -584,8 +579,8 @@
584579 return n;
585580 }
586581
587
-static void __hist_entry__set_folding(struct hist_entry *he,
588
- struct hist_browser *hb, bool unfold)
582
+static void hist_entry__set_folding(struct hist_entry *he,
583
+ struct hist_browser *hb, bool unfold)
589584 {
590585 hist_entry__init_have_children(he);
591586 he->unfolded = unfold ? he->has_children : false;
....@@ -603,34 +598,12 @@
603598 he->nr_rows = 0;
604599 }
605600
606
-static void hist_entry__set_folding(struct hist_entry *he,
607
- struct hist_browser *browser, bool unfold)
608
-{
609
- double percent;
610
-
611
- percent = hist_entry__get_percent_limit(he);
612
- if (he->filtered || percent < browser->min_pcnt)
613
- return;
614
-
615
- __hist_entry__set_folding(he, browser, unfold);
616
-
617
- if (!he->depth || unfold)
618
- browser->nr_hierarchy_entries++;
619
- if (he->leaf)
620
- browser->nr_callchain_rows += he->nr_rows;
621
- else if (unfold && !hist_entry__has_hierarchy_children(he, browser->min_pcnt)) {
622
- browser->nr_hierarchy_entries++;
623
- he->has_no_entry = true;
624
- he->nr_rows = 1;
625
- } else
626
- he->has_no_entry = false;
627
-}
628
-
629601 static void
630602 __hist_browser__set_folding(struct hist_browser *browser, bool unfold)
631603 {
632604 struct rb_node *nd;
633605 struct hist_entry *he;
606
+ double percent;
634607
635608 nd = rb_first_cached(&browser->hists->entries);
636609 while (nd) {
....@@ -640,6 +613,21 @@
640613 nd = __rb_hierarchy_next(nd, HMD_FORCE_CHILD);
641614
642615 hist_entry__set_folding(he, browser, unfold);
616
+
617
+ percent = hist_entry__get_percent_limit(he);
618
+ if (he->filtered || percent < browser->min_pcnt)
619
+ continue;
620
+
621
+ if (!he->depth || unfold)
622
+ browser->nr_hierarchy_entries++;
623
+ if (he->leaf)
624
+ browser->nr_callchain_rows += he->nr_rows;
625
+ else if (unfold && !hist_entry__has_hierarchy_children(he, browser->min_pcnt)) {
626
+ browser->nr_hierarchy_entries++;
627
+ he->has_no_entry = true;
628
+ he->nr_rows = 1;
629
+ } else
630
+ he->has_no_entry = false;
643631 }
644632 }
645633
....@@ -659,8 +647,10 @@
659647 if (!browser->he_selection)
660648 return;
661649
662
- hist_entry__set_folding(browser->he_selection, browser, unfold);
663
- browser->b.nr_entries = hist_browser__nr_entries(browser);
650
+ if (unfold == browser->he_selection->unfolded)
651
+ return;
652
+
653
+ hist_browser__toggle_fold(browser);
664654 }
665655
666656 static void ui_browser__warn_lost_events(struct ui_browser *browser)
....@@ -731,8 +721,8 @@
731721 hist_browser__set_folding(browser, true);
732722 break;
733723 case 'e':
734
- /* Expand the selected entry. */
735
- hist_browser__set_folding_selected(browser, !hist_browser__he_selection_unfolded(browser));
724
+ /* Toggle expand/collapse the selected entry. */
725
+ hist_browser__toggle_fold(browser);
736726 break;
737727 case 'H':
738728 browser->show_headers = !browser->show_headers;
....@@ -1778,7 +1768,7 @@
17781768 hists_browser__scnprintf_hierarchy_headers(browser, headers,
17791769 sizeof(headers));
17801770
1781
- ui_browser__gotorc(&browser->b, 0, 0);
1771
+ ui_browser__gotorc_title(&browser->b, 0, 0);
17821772 ui_browser__set_color(&browser->b, HE_COLORSET_ROOT);
17831773 ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1);
17841774 }