.. | .. |
---|
407 | 407 | return container_of(ms, struct callchain_list, ms)->has_children; |
---|
408 | 408 | } |
---|
409 | 409 | |
---|
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 | | - |
---|
415 | 410 | static bool hist_browser__selection_unfolded(struct hist_browser *browser) |
---|
416 | 411 | { |
---|
417 | 412 | struct hist_entry *he = browser->he_selection; |
---|
.. | .. |
---|
584 | 579 | return n; |
---|
585 | 580 | } |
---|
586 | 581 | |
---|
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) |
---|
589 | 584 | { |
---|
590 | 585 | hist_entry__init_have_children(he); |
---|
591 | 586 | he->unfolded = unfold ? he->has_children : false; |
---|
.. | .. |
---|
603 | 598 | he->nr_rows = 0; |
---|
604 | 599 | } |
---|
605 | 600 | |
---|
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 | | - |
---|
629 | 601 | static void |
---|
630 | 602 | __hist_browser__set_folding(struct hist_browser *browser, bool unfold) |
---|
631 | 603 | { |
---|
632 | 604 | struct rb_node *nd; |
---|
633 | 605 | struct hist_entry *he; |
---|
| 606 | + double percent; |
---|
634 | 607 | |
---|
635 | 608 | nd = rb_first_cached(&browser->hists->entries); |
---|
636 | 609 | while (nd) { |
---|
.. | .. |
---|
640 | 613 | nd = __rb_hierarchy_next(nd, HMD_FORCE_CHILD); |
---|
641 | 614 | |
---|
642 | 615 | 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; |
---|
643 | 631 | } |
---|
644 | 632 | } |
---|
645 | 633 | |
---|
.. | .. |
---|
659 | 647 | if (!browser->he_selection) |
---|
660 | 648 | return; |
---|
661 | 649 | |
---|
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); |
---|
664 | 654 | } |
---|
665 | 655 | |
---|
666 | 656 | static void ui_browser__warn_lost_events(struct ui_browser *browser) |
---|
.. | .. |
---|
731 | 721 | hist_browser__set_folding(browser, true); |
---|
732 | 722 | break; |
---|
733 | 723 | 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); |
---|
736 | 726 | break; |
---|
737 | 727 | case 'H': |
---|
738 | 728 | browser->show_headers = !browser->show_headers; |
---|
.. | .. |
---|
1778 | 1768 | hists_browser__scnprintf_hierarchy_headers(browser, headers, |
---|
1779 | 1769 | sizeof(headers)); |
---|
1780 | 1770 | |
---|
1781 | | - ui_browser__gotorc(&browser->b, 0, 0); |
---|
| 1771 | + ui_browser__gotorc_title(&browser->b, 0, 0); |
---|
1782 | 1772 | ui_browser__set_color(&browser->b, HE_COLORSET_ROOT); |
---|
1783 | 1773 | ui_browser__write_nstring(&browser->b, headers, browser->b.width + 1); |
---|
1784 | 1774 | } |
---|