Messages in this thread | | | From | Charles Baylis <> | Date | Sat, 25 Feb 2017 13:06:28 +0000 | Subject | Re: [PATCH] perf report: Allow sorting by symbol size. |
| |
On 24 February 2017 at 19:22, Arnaldo Carvalho de Melo <acme@kernel.org> wrote: >> >> +/* --sort symbol_size */ >> + >> +static int64_t _sort__sym_size_cmp(struct symbol *sym_l, struct symbol *sym_r) >> +{ >> + int64_t size_l = sym_l != NULL ? sym_l->end - sym_l->start : 0; >> + int64_t size_r = sym_r != NULL ? sym_r->end - sym_r->start : 0; > > We have symbol__size(), no need to open code it, I'll fix it
OK thanks.
>> + >> + return size_l < size_r ? -1 : >> + size_l == size_r ? 0 : 1; >> +} >> + >> +static int64_t >> +sort__sym_size_cmp(struct hist_entry *left, struct hist_entry *right) >> +{ >> + return _sort__sym_size_cmp(right->ms.sym, left->ms.sym); >> +} >> + >> +static int _hist_entry__sym_size_snprintf(struct symbol *sym, char *bf, >> + size_t bf_size, unsigned int width) >> +{ >> + if (sym) { >> + int64_t sym_size = sym->end - sym->start; > > > Ditto > >> + >> + return repsep_snprintf(bf, bf_size, "%*lld", width, >> + (long long)sym_size); > > Humm, why use lld instead of plain d, that way you can get rid of that > (long long)? I'm fixing this as well
struct symbol defines start and end as u64, so it seemed prudent to treat the size as 64 bit too. However, since symbol__size() returns size_t, the best thing to write is probably
return repsep_snprintf(bf, bf_size, "%*zu", width, symbol__size(sym));
| |