Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1231313imm; Tue, 5 Jun 2018 11:03:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL8t/2w4WA9sBRFzVl6AU27JIjh6VtSmFTYSTRZ4tTXvpV1Yyn0id4KTL7tLHCd/s40GNHD X-Received: by 2002:a17:902:650c:: with SMTP id b12-v6mr10006718plk.31.1528221831232; Tue, 05 Jun 2018 11:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528221831; cv=none; d=google.com; s=arc-20160816; b=DaLatB3HlMjUulu84mRGs1ade66qQQO0BpIm8g9/GgMiZeGYS+OmVmUC1EA0RzdfDg eYbv1DaWOGZYklgk/LBU5Vm2oDQ5WmNnDsD7LywnTEbovTAcbL3SzJ8IzMik/A8/J5nH XHsayLSTVl8jA3hlyBtUhRojO/lbAUsbv5+ufMzbZCHLADi8GCWQIaIoehJbM+9hn1KK mZwK92KSnmxH5DeFhAcMz7FqzNeyz7z8iuBCYhvPuwTNEo4CLInOF78DsAnSWXjgZu64 9Aacs9/fmEaDwwmVjIcDqZbyc8o8MgniPGXBR+AqHIffNRlCJb9WHaTcsl78DGhBjMzO EOLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=30a9IxGYezHltwMtrLyB3z/USE5xOJgGjBkhJqi6L1c=; b=FMtTPVXVRz3lqG1SJ2WzI8iuy78Tkni3j7dSl0fVL09wWuISgB3lxZrbZWT0QP8if6 +LG3Cmk6NYuRE5Vu8Qy8FVP6enPU9yCRZ5mbpYz0grxqxGvIcHJsSYhqCSTiabi8T8fn eLOkoWAepSpX2X6y6nCa+oDxvGFztfhz/h9M3BuhH2XnRZAiiKVpFX6jOtTeqBiaHN4P 8br8C9ai1od5V8cj7tSgXr8tmNFA3VLjscstHVvio6GNj4A+6Lx07oUAQrisfZIB3r3d 0F3b5VCqQ81nM5Jbf0yqUnf8nLugXBNClghg9ch+BwpbjzIQLk2PjtDTmaDF/nFCmyM4 T1gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n8YNTMjB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8-v6si49803730pfi.115.2018.06.05.11.03.36; Tue, 05 Jun 2018 11:03:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=n8YNTMjB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753088AbeFESDM (ORCPT + 99 others); Tue, 5 Jun 2018 14:03:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:45984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbeFERvi (ORCPT ); Tue, 5 Jun 2018 13:51:38 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 786662083B; Tue, 5 Jun 2018 17:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528221097; bh=yX72axOqL7o1xuH9MEvOukjKAJbj89GLvYjTyD7yfcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n8YNTMjBR2VMfX3UrwD3hfagLcFZwGOK20xJomQXFWdlCDYe7eB1SRAFz4euimHoh eNBuL6E8FOSR/yYigF5l8LBnIJadl0xG1pyzvSdV5ne2Sp8Ru5eocZzB9XRCbnEGp+ kSiYkVLnxnCj9rxjxxWfMWq1kv+acsNn9gAzjEfA= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 19/46] perf sort: Introduce addr_map_symbol__srcline() to make code more compact Date: Tue, 5 Jun 2018 14:50:03 -0300 Message-Id: <20180605175030.32549-20-acme@kernel.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180605175030.32549-1-acme@kernel.org> References: <20180605175030.32549-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo Since we have 'struct addr_map_symbol' and the srcline sort order keys all operate on those, make the code more compact by introducing a function that receives a pointer to such struct and expands the arguments to map__srcline(). Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-j540wq7n3ukkh70gk5be0in5@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/sort.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 71096dbfeb88..4ab0b4ab24e4 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -365,19 +365,20 @@ struct sort_entry sort_srcline = { /* --sort srcline_from */ +static char *addr_map_symbol__srcline(struct addr_map_symbol *ams) +{ + return map__srcline(ams->map, ams->al_addr, ams->sym); +} + static int64_t sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) { - if (!left->branch_info->srcline_from) { - left->branch_info->srcline_from = map__srcline(left->branch_info->from.map, - left->branch_info->from.al_addr, - left->branch_info->from.sym); - } - if (!right->branch_info->srcline_from) { - right->branch_info->srcline_from = map__srcline(right->branch_info->from.map, - right->branch_info->from.al_addr, - right->branch_info->from.sym); - } + if (!left->branch_info->srcline_from) + left->branch_info->srcline_from = addr_map_symbol__srcline(&left->branch_info->from); + + if (!right->branch_info->srcline_from) + right->branch_info->srcline_from = addr_map_symbol__srcline(&right->branch_info->from); + return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); } @@ -399,16 +400,12 @@ struct sort_entry sort_srcline_from = { static int64_t sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) { - if (!left->branch_info->srcline_to) { - left->branch_info->srcline_to = map__srcline(left->branch_info->to.map, - left->branch_info->to.al_addr, - left->branch_info->to.sym); - } - if (!right->branch_info->srcline_to) { - right->branch_info->srcline_to = map__srcline(right->branch_info->to.map, - right->branch_info->to.al_addr, - right->branch_info->to.sym); - } + if (!left->branch_info->srcline_to) + left->branch_info->srcline_to = addr_map_symbol__srcline(&left->branch_info->to); + + if (!right->branch_info->srcline_to) + right->branch_info->srcline_to = addr_map_symbol__srcline(&right->branch_info->to); + return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); } -- 2.14.3