Re: [PATCH v2 7/7] perf expr: Migrate expr ids table to a hashmap

From: Ian Rogers
Date: Fri May 15 2020 - 18:59:45 EST


On Fri, May 15, 2020 at 3:41 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Fri, May 15, 2020 at 09:50:07AM -0700, Ian Rogers wrote:
>
> SNIP
>
> > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c
> > index 8b4ce704a68d..f64ab91c432b 100644
> > --- a/tools/perf/util/expr.c
> > +++ b/tools/perf/util/expr.c
> > @@ -4,25 +4,76 @@
> > #include "expr.h"
> > #include "expr-bison.h"
> > #include "expr-flex.h"
> > +#include <linux/kernel.h>
> >
> > #ifdef PARSER_DEBUG
> > extern int expr_debug;
> > #endif
> >
> > +static size_t key_hash(const void *key, void *ctx __maybe_unused)
> > +{
> > + const char *str = (const char *)key;
> > + size_t hash = 0;
> > +
> > + while (*str != '\0') {
> > + hash *= 31;
> > + hash += *str;
> > + str++;
> > + }
> > + return hash;
> > +}
> > +
> > +static bool key_equal(const void *key1, const void *key2,
> > + void *ctx __maybe_unused)
> > +{
> > + return !strcmp((const char *)key1, (const char *)key2);
>
> should that be strcasecmp ? would it affect the key_hash as well?

The original code does make use of strcasecmp in one place, but in the
group matching (the main useless use for this code) it doesn't. I
don't think it is a regression to keep it as this, and would like a
test case for when it does matter. Is that ok?

Thanks,
Ian

> jirka
>