linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	Miguel Ojeda <ojeda@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>
Subject: Re: [PATCH 4/6] fixdep: refactor hash table lookup
Date: Tue, 3 Jan 2023 21:45:50 +0100	[thread overview]
Message-ID: <CANiq72n6ZLcNRh=Ec1xCSNJtb=KZNMA-MMrtd8=DyUL4-2i_0w@mail.gmail.com> (raw)
In-Reply-To: <20221231064203.1623793-5-masahiroy@kernel.org>

On Sat, Dec 31, 2022 at 7:42 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> +/*
> + * Lookup a string in the hash table. If found, just return true.
> + * If not, add it to the hashtable and return false.
> + */
> +static bool in_hashtable(const char *name, int len, struct item *hashtab[])

I think readers may find a bit surprising that a function named
`in_hashtable` mutates the table. Should we use a better name? Perhaps
`ensure_in_hashtable`?

In other words, the function is really "insert if not already there
and return the previous state". Similar methods in C++ and Rust are
called `insert`, though they return the opposite, i.e. whether the
insertion took place. If we did that, then `insert_into_hashtable` may
be a good name instead.

> +       unsigned int hash = strhash(name, len);

Nit: this could be `const`, but I see we are not using it in
`fixdep.c` (for non-pointees) and it was not done in the original. But
it could be nice to start...

Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Tested-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel

  reply	other threads:[~2023-01-03 20:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-31  6:41 [PATCH 0/6] kbuild: fix dep-file processing for rust Masahiro Yamada
2022-12-31  6:41 ` [PATCH 1/6] kbuild: specify output names separately for each emission type from rustc Masahiro Yamada
2022-12-31 20:01   ` Gary Guo
2023-01-03 20:44   ` Miguel Ojeda
2023-01-07  9:09     ` Masahiro Yamada
2023-01-06  9:24   ` Vincenzo
2022-12-31  6:41 ` [PATCH 2/6] fixdep: parse Makefile more correctly to handle comments etc Masahiro Yamada
2022-12-31 15:25   ` Miguel Ojeda
2022-12-31 15:30     ` Miguel Ojeda
2023-01-03 20:45   ` Miguel Ojeda
2022-12-31  6:42 ` [PATCH 3/6] kbuild: remove sed commands after rustc rules Masahiro Yamada
2023-01-03 20:45   ` Miguel Ojeda
2023-01-06  9:28   ` Vincenzo
2022-12-31  6:42 ` [PATCH 4/6] fixdep: refactor hash table lookup Masahiro Yamada
2023-01-03 20:45   ` Miguel Ojeda [this message]
2022-12-31  6:42 ` [PATCH 5/6] fixdep: avoid parsing the same file over again Masahiro Yamada
2023-01-03 20:46   ` Miguel Ojeda
2023-01-06  9:31   ` Vincenzo
2022-12-31  6:42 ` [PATCH 6/6] fixdep: do not parse *.so, *.rmeta, *.rlib Masahiro Yamada
2023-01-03 20:46   ` Miguel Ojeda
2022-12-31 13:34 ` [PATCH 0/6] kbuild: fix dep-file processing for rust Miguel Ojeda
2022-12-31 15:05   ` Masahiro Yamada
2023-01-03 20:48     ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANiq72n6ZLcNRh=Ec1xCSNJtb=KZNMA-MMrtd8=DyUL4-2i_0w@mail.gmail.com' \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=ojeda@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).