From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27804 invoked by alias); 23 Oct 2019 22:54:37 -0000 Mailing-List: contact gdb-testers-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-testers-owner@sourceware.org Received: (qmail 27788 invoked by uid 89); 23 Oct 2019 22:54:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Oct 2019 22:54:36 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] Add a fast_hash function in common-utils From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <1a6ff1a96b302283d517b3cdeae7310adecbe859@gdb-build> Date: Wed, 23 Oct 2019 22:54:00 -0000 X-SW-Source: 2019-q4/txt/msg01357.txt.bz2 *** TEST RESULTS FOR COMMIT 1a6ff1a96b302283d517b3cdeae7310adecbe859 *** commit 1a6ff1a96b302283d517b3cdeae7310adecbe859 Author: Christian Biesinger AuthorDate: Fri Sep 27 13:08:25 2019 -0500 Commit: Christian Biesinger CommitDate: Tue Oct 22 11:26:17 2019 -0500 Add a fast_hash function in common-utils Also updates a caller in symtab.c. For now this just calls htab_hash_string but the next patch will change it to xxhash, if available. gdb/ChangeLog: 2019-10-22 Christian Biesinger * utils.h (fast_hash): New function. * symtab.c (hash_demangled_name_entry): Call new function fast_hash. Change-Id: I77cac0d9aa78fc65316a2af449f52edcae72dc9b diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d271330400..bbf5d0897d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-10-22 Christian Biesinger + + * utils.h (fast_hash): New function. + * symtab.c (hash_demangled_name_entry): Call new function + fast_hash. + 2019-10-22 Christian Biesinger * symtab.c (struct demangled_name_entry): Change type of mangled diff --git a/gdb/symtab.c b/gdb/symtab.c index 567d09d355..dff92ca203 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -70,6 +70,7 @@ #include #include "gdbsupport/gdb_string_view.h" #include "gdbsupport/pathstuff.h" +#include "gdbsupport/common-utils.h" /* Forward declarations for local functions. */ @@ -727,7 +728,7 @@ hash_demangled_name_entry (const void *data) const struct demangled_name_entry *e = (const struct demangled_name_entry *) data; - return iterative_hash (e->mangled.data (), e->mangled.length (), 0); + return fast_hash (e->mangled.data (), e->mangled.length ()); } /* Equality function for the demangled name hash. */ diff --git a/gdb/utils.h b/gdb/utils.h index af8b461b6e..478c485e66 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -567,4 +567,14 @@ extern void copy_bitwise (gdb_byte *dest, ULONGEST dest_offset, const gdb_byte *source, ULONGEST source_offset, ULONGEST nbits, int bits_big_endian); +/* A fast hashing function. This can be used to hash strings in a fast way + when the length is known. If no fast hashing library is available, falls + back to iterative_hash from libiberty. */ + +static inline unsigned int +fast_hash (const char* str, size_t len) +{ + return iterative_hash (str, len, 0); +} + #endif /* UTILS_H */