From patchwork Fri Sep 27 19:18:43 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: 34692 Received: (qmail 96167 invoked by alias); 27 Sep 2019 19:18:59 -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 96075 invoked by uid 89); 27 Sep 2019 19:18:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 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=5466, utilsc, utils.c, UD:utils.c X-HELO: mail-yb1-f201.google.com Received: from mail-yb1-f201.google.com (HELO mail-yb1-f201.google.com) (209.85.219.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Sep 2019 19:18:57 +0000 Received: by mail-yb1-f201.google.com with SMTP id h66so5161141ybg.0 for ; Fri, 27 Sep 2019 12:18:57 -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=D+i2s0SvE3gV6aZugtgA8ebNzU8NkvPkWgjNeI2j1io=; b=g3Xp2r9zB7Mp5ib+Mh4iyYNkJIayOq9EDNSIpLS7b/Mv2ecFLl2z5oXy4Vo5mljzMz UQ5I2w0ZlBHQwqehCP1bPLRrw7w8pCBfPi5VDXCHoHMi7OtxspICUOqv0TwRUUUbgLta Iold4qDXZerMhe3l1JHLBG86IFn6p4WmKEzaZQN93JzDAB3NDBjbKYxRlr7gOttS/Yhn OlhQ7wH1je6oLmJ5U2nZQcwYnmafuFADz8BUyqzZv8Fnxb1xAmyO67P4TgCKs/3x5now CjGcsfF4zhPizSEJOJVLx8qTO2IB6IQ27Sdz5SWNlqD87h7ssWp9zwFnShmxWqDYp+q/ xqSQ== Date: Fri, 27 Sep 2019 14:18:43 -0500 In-Reply-To: <20190927191844.43675-1-cbiesinger@google.com> Message-Id: <20190927191844.43675-3-cbiesinger@google.com> Mime-Version: 1.0 References: <20190927191844.43675-1-cbiesinger@google.com> Subject: [PATCH 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 | 7 +++++++ gdb/utils.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index c9cee0bca2..6ba78c92ac 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 htab_hash_string (e->mangled.data ()); + 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 b7d380073f..ef010996c1 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3377,6 +3377,13 @@ copy_bitwise (gdb_byte *dest, ULONGEST dest_offset, } } +unsigned int +fast_hash (const char* str, size_t len) +{ + gdb_assert (str[len] == '\0'); + return htab_hash_string (str); +} + void _initialize_utils (void) { diff --git a/gdb/utils.h b/gdb/utils.h index 7df86beec4..61f331dc92 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -546,4 +546,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 */