perf tools: Add same_cmd_with_prefix() helper
Wrap repeated code in helper function same_cmd_with_prefix for more clearly. Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: https://lore.kernel.org/r/20220906032906.21395-2-shangxiaojing@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
b304c173e3
commit
4fb47c8c20
@ -99,10 +99,16 @@ struct pager_config {
|
||||
int val;
|
||||
};
|
||||
|
||||
static bool same_cmd_with_prefix(const char *var, struct pager_config *c,
|
||||
const char *header)
|
||||
{
|
||||
return (strstarts(var, header) && !strcmp(var + strlen(header), c->cmd));
|
||||
}
|
||||
|
||||
static int pager_command_config(const char *var, const char *value, void *data)
|
||||
{
|
||||
struct pager_config *c = data;
|
||||
if (strstarts(var, "pager.") && !strcmp(var + 6, c->cmd))
|
||||
if (same_cmd_with_prefix(var, c, "pager."))
|
||||
c->val = perf_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
@ -121,9 +127,9 @@ static int check_pager_config(const char *cmd)
|
||||
static int browser_command_config(const char *var, const char *value, void *data)
|
||||
{
|
||||
struct pager_config *c = data;
|
||||
if (strstarts(var, "tui.") && !strcmp(var + 4, c->cmd))
|
||||
if (same_cmd_with_prefix(var, c, "tui."))
|
||||
c->val = perf_config_bool(var, value);
|
||||
if (strstarts(var, "gtk.") && !strcmp(var + 4, c->cmd))
|
||||
if (same_cmd_with_prefix(var, c, "gtk."))
|
||||
c->val = perf_config_bool(var, value) ? 2 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user