@@ -564,64 +564,18 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
564
564
}
565
565
}
566
566
567
- /*
568
- * reverse the map, sort on period.
569
- */
570
-
571
- static int period_cmp (u64 period_a , u64 period_b )
567
+ static int hist_entry__sort (struct hist_entry * a , struct hist_entry * b )
572
568
{
573
- if (period_a > period_b )
574
- return 1 ;
575
- if (period_a < period_b )
576
- return -1 ;
577
- return 0 ;
578
- }
579
-
580
- static int hist_entry__sort_on_period (struct hist_entry * a ,
581
- struct hist_entry * b )
582
- {
583
- int ret ;
584
- int i , nr_members ;
585
- struct perf_evsel * evsel ;
586
- struct hist_entry * pair ;
587
- u64 * periods_a , * periods_b ;
588
-
589
- ret = period_cmp (a -> stat .period , b -> stat .period );
590
- if (ret || !symbol_conf .event_group )
591
- return ret ;
592
-
593
- evsel = hists_to_evsel (a -> hists );
594
- nr_members = evsel -> nr_members ;
595
- if (nr_members <= 1 )
596
- return ret ;
597
-
598
- periods_a = zalloc (sizeof (periods_a ) * nr_members );
599
- periods_b = zalloc (sizeof (periods_b ) * nr_members );
600
-
601
- if (!periods_a || !periods_b )
602
- goto out ;
603
-
604
- list_for_each_entry (pair , & a -> pairs .head , pairs .node ) {
605
- evsel = hists_to_evsel (pair -> hists );
606
- periods_a [perf_evsel__group_idx (evsel )] = pair -> stat .period ;
607
- }
608
-
609
- list_for_each_entry (pair , & b -> pairs .head , pairs .node ) {
610
- evsel = hists_to_evsel (pair -> hists );
611
- periods_b [perf_evsel__group_idx (evsel )] = pair -> stat .period ;
612
- }
569
+ struct perf_hpp_fmt * fmt ;
570
+ int64_t cmp = 0 ;
613
571
614
- for ( i = 1 ; i < nr_members ; i ++ ) {
615
- ret = period_cmp ( periods_a [ i ], periods_b [ i ] );
616
- if (ret )
572
+ perf_hpp__for_each_format ( fmt ) {
573
+ cmp = fmt -> sort ( a , b );
574
+ if (cmp )
617
575
break ;
618
576
}
619
577
620
- out :
621
- free (periods_a );
622
- free (periods_b );
623
-
624
- return ret ;
578
+ return cmp ;
625
579
}
626
580
627
581
static void hists__reset_filter_stats (struct hists * hists )
@@ -669,7 +623,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
669
623
parent = * p ;
670
624
iter = rb_entry (parent , struct hist_entry , rb_node );
671
625
672
- if (hist_entry__sort_on_period (he , iter ) > 0 )
626
+ if (hist_entry__sort (he , iter ) > 0 )
673
627
p = & (* p )-> rb_left ;
674
628
else
675
629
p = & (* p )-> rb_right ;
0 commit comments