Commit 7aea01ea authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf help: Lower levenshtein penality for deleting character

The levenshtein penalty for deleting a character was far higher than
subsituting or inserting a character. Lower the penalty to match that
of inserting a character.

Before:

  $ perf recccord
  perf: 'recccord' is not a perf-command. See 'perf --help'.
  $

After:

  $ perf recccord
  perf: 'recccord' is not a perf-command. See 'perf --help'.

  Did you mean this?
          record
  $
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
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/20240301201306.2680986-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f664d515
......@@ -73,10 +73,14 @@ const char *help_unknown_cmd(const char *cmd, struct cmdnames *main_cmds)
if (main_cmds->cnt) {
/* This reuses cmdname->len for similarity index */
for (i = 0; i < main_cmds->cnt; ++i)
for (i = 0; i < main_cmds->cnt; ++i) {
main_cmds->names[i]->len =
levenshtein(cmd, main_cmds->names[i]->name, 0, 2, 1, 4);
levenshtein(cmd, main_cmds->names[i]->name,
/*swap_penalty=*/0,
/*substition_penality=*/2,
/*insertion_penality=*/1,
/*deletion_penalty=*/1);
}
qsort(main_cmds->names, main_cmds->cnt,
sizeof(*main_cmds->names), levenshtein_compare);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment