From patchwork Tue Oct 8 16:09:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Terekhov, Mikhail via Gdb-patches" X-Patchwork-Id: 34875 Received: (qmail 15107 invoked by alias); 8 Oct 2019 16:09:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 15065 invoked by uid 89); 8 Oct 2019 16:09:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 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: mail-ua1-f73.google.com Received: from mail-ua1-f73.google.com (HELO mail-ua1-f73.google.com) (209.85.222.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Oct 2019 16:09:45 +0000 Received: by mail-ua1-f73.google.com with SMTP id 4so3230053uay.14 for ; Tue, 08 Oct 2019 09:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Vgs0DqwkaiEanqZLPXtTqH5401Iy/47rr7diFFhI5HI=; b=ImHu0dUThaaPJJceqOuiFZGtmFykCrRQTYy/xIbJz1pkPpF3J0o6Q+6JrbgtGicA0n jtH+6RTzyBsuweQps07XYoOl1OARAMK04x6SvE1aNcqfpeZkrrhj3iYjMvh017XSnBDp z/2ddxdJMhyMi7C5vbu/poceX46SgNyBI065CnSIELLsUqOpZyMFgtL89vI6u/tcV1fz NG6o7AnXB/rkFo6e8krJpM9NmSgV7skmK8quAgqVuB7cZNRFKDN/3cysG3fQSkMh8Pxr MTlX+g/pUt+VNpOzKvlGGwRRnXPxg58iDa8OwfgcixBaN+z3w4QZ29AUmM6POPgjxiUn Xskg== Date: Tue, 8 Oct 2019 11:09:32 -0500 In-Reply-To: <20191008160933.155975-1-cbiesinger@google.com> Message-Id: <20191008160933.155975-3-cbiesinger@google.com> Mime-Version: 1.0 References: <20191008160933.155975-1-cbiesinger@google.com> Subject: [PATCH v2 2/3] Add a fast_hash function in common-utils X-Patchwork-Original-From: "Christian Biesinger via gdb-patches" From: "Terekhov, Mikhail via Gdb-patches" Reply-To: Christian Biesinger To: gdb-patches@sourceware.org Cc: Christian Biesinger X-IsSubscribed: yes 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-09-27 Christian Biesinger * utils.c (fast_hash): New function. * utils.h (fast_hash): New function. * symtab.c (hash_demangled_name_entry): Call new function fast_hash. --- gdb/symtab.c | 3 ++- gdb/utils.c | 6 ++++++ gdb/utils.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 0724110d12..2577f3909a 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.c b/gdb/utils.c index e685cc2084..8615820c46 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3436,6 +3436,12 @@ copy_bitwise (gdb_byte *dest, ULONGEST dest_offset, } } +unsigned int +fast_hash (const char* str, size_t len) +{ + return iterative_hash (str, len, 0); +} + void _initialize_utils (void) { diff --git a/gdb/utils.h b/gdb/utils.h index 76f0da69f7..7101add394 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -569,4 +569,6 @@ extern void copy_bitwise (gdb_byte *dest, ULONGEST dest_offset, const gdb_byte *source, ULONGEST source_offset, ULONGEST nbits, int bits_big_endian); +extern unsigned int fast_hash (const char* str, size_t len); + #endif /* UTILS_H */