Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12409916rwl; Tue, 3 Jan 2023 14:03:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXsjMOC/+N+I33QF2fXoHhkd2ycIY6i15dnOdPn6902VVRRJ5lMKTZCYPJcJJXzIAbttMkN+ X-Received: by 2002:a17:90b:48cd:b0:226:4531:4c74 with SMTP id li13-20020a17090b48cd00b0022645314c74mr15436135pjb.37.1672783412075; Tue, 03 Jan 2023 14:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672783412; cv=none; d=google.com; s=arc-20160816; b=FWmvLWVRE01mjbvqkVy1YQIwpszaowpTexmPTXkDX6IbKtrcrYloPbm09DMFt3Uj9O IpHd7TVrS7GaCh5xZAIvKMmpYz5Uxq+nt1ptFGrtjkX2DUEhGVT1AXnI8XeO28f3+qwM uWC4WjZ4OjxwOs7tB9oDfmBi7Fqcgyn7e8CdbWDbJBxYAup6aPp33MSKNc27p0JSQXg4 lR5RzmHUTYUaRq4mUug/sHmpP/VyGDOAtMYN5PxzfS0htqvEVvgicfV6CuzmKEwfbfSR eYj+TfkWDkgqg6stauLrNxza13tLLHMVvNcCqW/LueGHqh3ac4EYJb9EKrOSV+D2cq0q IWfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=XKlQpt6uvL07Ls9Ei/49KiHiJ6/fe4cVnWR4L1LQ220=; b=gBZZrxYXM9r2IhE2Vr7e7Mwz5/qXjMZOCDQg8xMMa36dR8ovFP6uhWUcZ18SPlPZYv G6TLNI4nefJkSwp205ILxU5Dtp15utliIPuZpXStRSsVdR+8ZtEynsK3MuQK/WkSgo+r ROOLR/Z2Ux40yC9B8+40WB4wokvkD/+R4UXZR6o6qHiWVuC6M2fOnaLqcl2Nt+3NMIBA PC5WdLksceae2qxS9tbPabf2tlCJyMM1MKnNlJWZhw9fu6XfdN6lzeBD4vEKhFkgMhYW gE1nyAQE0g3IJDxi+HE53RmtINdDQMXmlImU2R1Q23SbbqbdFplQno7assy9ANCADmki F3UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C+uywNvI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ns11-20020a17090b250b00b002191b3c187csi30800745pjb.165.2023.01.03.14.03.24; Tue, 03 Jan 2023 14:03:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C+uywNvI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238824AbjACUqL (ORCPT + 59 others); Tue, 3 Jan 2023 15:46:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238888AbjACUqD (ORCPT ); Tue, 3 Jan 2023 15:46:03 -0500 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DEAB14D33; Tue, 3 Jan 2023 12:46:02 -0800 (PST) Received: by mail-yb1-xb36.google.com with SMTP id l139so147035ybl.12; Tue, 03 Jan 2023 12:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XKlQpt6uvL07Ls9Ei/49KiHiJ6/fe4cVnWR4L1LQ220=; b=C+uywNvIs96mrpcs8fb9YrHTM4aboYcLDJfhJlb7po5ITqZtHOrUtmzsYWQy3B89OK EMJPu9xZwpoU6esWMrSY4bCE5sMvvHx5UAXTfm4zMFhyWJ4KhKj46sgFWvdm58Q7aDon tjP1T2rRw9+rnRj+Epnvf3JMRWTVNAD/96jMd3aWpPrWzlD1Vkfd+OyorbiMZcytLLzy KWYonAJQ2goHtacYwczR7kBfenQrHKF9xevx92mOhiBGZWG9LYoXg8PHONUsFSVoSU5C 67g5zJzzdH5RY1XR0GYh/DCh+D4wNP+h690adCquoqoR5M80HXEmWLfn9DbqGhZYlkZV DkbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XKlQpt6uvL07Ls9Ei/49KiHiJ6/fe4cVnWR4L1LQ220=; b=GVdBShq84iL7gXZs+yep+8Q6GU2BVAcW8BFOvsPFlNMFoIy/k3H+WLOVIA8G1F8bv/ LBDNrBuPjMXzngkW9+gWZoy7DIFyUwPbgDYXSCLPUfKSXWewm23COwRMs+Y1Mm49gSTR 8iPvTcFxH5Iq+z4gatA3Xqu/Ek2rw2oDoJZuAMQQlycNOoyfwgCN2P+wX4ZzysF7xOJ2 HYEv32b7oXlwQPAPeKDZGA5Pz3f7j/1wdl0t4QNSncdePQbMkttEvmv6tWBN9BkCFyXN yUuTN77e8r/EhZhpstCDNsuXF/ZP5pkY4N4CSxikIpaBILIVME6Cet/vFpb9Akso6+c7 zLGw== X-Gm-Message-State: AFqh2koWwqLq5eaPHkWHh0lvnUYycK+AXaPUbWyMcNadpq1dck6TnIs/ ACAGaY7bG2GIxpPF5m7NoTPSi2voSGaZUhbdnLnWeI+EtzeXG+Fs X-Received: by 2002:a25:e6c1:0:b0:761:d9ec:328f with SMTP id d184-20020a25e6c1000000b00761d9ec328fmr4293632ybh.507.1672778761493; Tue, 03 Jan 2023 12:46:01 -0800 (PST) MIME-Version: 1.0 References: <20221231064203.1623793-1-masahiroy@kernel.org> <20221231064203.1623793-5-masahiroy@kernel.org> In-Reply-To: <20221231064203.1623793-5-masahiroy@kernel.org> From: Miguel Ojeda Date: Tue, 3 Jan 2023 21:45:50 +0100 Message-ID: Subject: Re: [PATCH 4/6] fixdep: refactor hash table lookup To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 31, 2022 at 7:42 AM Masahiro Yamada 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 Tested-by: Miguel Ojeda Cheers, Miguel