From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 07F061F5AE for ; Sat, 12 Jun 2021 00:21:36 +0000 (UTC) Received: from localhost ([::1]:57470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrrP4-0007oH-GD for normalperson@yhbt.net; Fri, 11 Jun 2021 20:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrrOx-0007o7-AT for bug-gnulib@gnu.org; Fri, 11 Jun 2021 20:21:27 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:38448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrrOu-0000No-UL for bug-gnulib@gnu.org; Fri, 11 Jun 2021 20:21:26 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 896E816011B for ; Fri, 11 Jun 2021 17:21:12 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id fCI1RVLwqVMb; Fri, 11 Jun 2021 17:21:05 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AA48416011A; Fri, 11 Jun 2021 17:21:05 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id AAG76P6McV6L; Fri, 11 Jun 2021 17:21:05 -0700 (PDT) Received: from day.example.com (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 76311160095; Fri, 11 Jun 2021 17:21:00 -0700 (PDT) From: Paul Eggert To: bug-gnulib@gnu.org Subject: [PATCH] exclude: improve wide-character hashing Date: Fri, 11 Jun 2021 17:20:54 -0700 Message-Id: <20210612002054.1105452-1-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" * lib/exclude.c (string_hasher_ci): Take the modulo at the end rather than each time a wide character is retrieved; this should be more efficient and should hash better. --- ChangeLog | 7 +++++++ lib/exclude.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d57d006ff..304599f81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-06-11 Paul Eggert + + exclude: improve wide-character hashing + * lib/exclude.c (string_hasher_ci): Take the modulo at the end + rather than each time a wide character is retrieved; this should + be more efficient and should hash better. + 2021-06-11 Bruno Haible =20 Make message in last commit more precise. diff --git a/lib/exclude.c b/lib/exclude.c index 4ef4e08f1..6287fbc68 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -219,10 +219,10 @@ string_hasher_ci (void const *data, size_t n_bucket= s) else wc =3D *m.ptr; =20 - value =3D (value * 31 + wc) % n_buckets; + value =3D value * 31 + wc; } =20 - return value; + return value % n_buckets; } =20 /* compare two strings for equality */ --=20 2.30.2