From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 6A536383FD66 for ; Tue, 6 Dec 2022 17:20:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A536383FD66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670347201; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=98glkovK0HSypUgn93WVY1i5mkIQlYZ6zxS3xX6dSso=; b=SX40F1RWhdZsWuknpkrXxiJ73VkGt/TsbTD9ppfqQoKPUoWSQnVv77wwU9gUTXf1rrAowx BiilipzlAJNTX0UPvW7+OgkDgA2Y53sJZM4Bp9NJgUSNyz1o0EO4XqcYL9XXe2wZ9pkQj2 5xdvZsoQfYp3/zaBpntjPYIq6A9tEEk= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-554-kEfFEKLnNxeIMbaFtn5TNA-1; Tue, 06 Dec 2022 12:20:00 -0500 X-MC-Unique: kEfFEKLnNxeIMbaFtn5TNA-1 Received: by mail-wm1-f71.google.com with SMTP id ay19-20020a05600c1e1300b003cf758f1617so10213207wmb.5 for ; Tue, 06 Dec 2022 09:19:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=98glkovK0HSypUgn93WVY1i5mkIQlYZ6zxS3xX6dSso=; b=APrHoyItsXxvpQMDmrG7NrAUAG9vhmFUJgKBjMROSZtE0ZDnVshYThtAjIvRNIzG/2 axDAG6Gkc1ipLRfPELDI6Jsh3INjCcbA+Zn6uzR/xuRNtAl7k3vYYIr+NDsNx3P+5XEl OQdU07vXfE7QLUjWJbUlzGbWI3ctC81DbbCCQOkOiWgw8X6WPgRaE5R/CN/dzt8B1cp/ xqj4FmLX3Qvo58phGgMwXI4u7imGqNHg6yBkjpuT0h7oASRMd0EaO+5GniMm+75hLsUt cO7G+YAopihIWjcdv1bUqKnf7/eitxJHEMsviNEvR9HGRCBeudmO6GS3at7nAjLOWb/3 hG9Q== X-Gm-Message-State: ANoB5pkoRuRvGhRwipvCTbqnkot57X0dEcEEma0AMjo/Euw3wTWip/Fn bvztboOF1fqu95WTIzWyLVCG6QjcgUAvbKsInMTPWahlWtSlF061mWfnPHxfcI1ZZBoEt2XcKIr Ww+48uRXORpsQp13ggZaQauD83ageu+g4GqOA0YOfAs6rVpOPxd8KeTx1No33RaKT6URK2xB6KA == X-Received: by 2002:a05:600c:198a:b0:3b4:8603:e2ae with SMTP id t10-20020a05600c198a00b003b48603e2aemr54517132wmq.148.1670347198757; Tue, 06 Dec 2022 09:19:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf47XqQQTHw6tRMuDgh6aCMFwL/pGsTB5fN27NuWEz1Wxo7Ea8yZjD2Qs1sC9IPXqREyZpHJZg== X-Received: by 2002:a05:600c:198a:b0:3b4:8603:e2ae with SMTP id t10-20020a05600c198a00b003b48603e2aemr54517116wmq.148.1670347198494; Tue, 06 Dec 2022 09:19:58 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id g16-20020a7bc4d0000000b003d1b4d957aasm9522769wmk.36.2022.12.06.09.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 09:19:58 -0800 (PST) From: Andrew Burgess To: Simon Marchi via Gdb-patches , gdb-patches@sourceware.org Cc: Simon Marchi Subject: Re: [PATCH 09/12] gdbsupport: add gdb::string_view_hash In-Reply-To: <20221206135729.3937767-10-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> <20221206135729.3937767-10-simon.marchi@efficios.com> Date: Tue, 06 Dec 2022 17:19:57 +0000 Message-ID: <87h6y830w2.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Simon Marchi via Gdb-patches writes: > Add the string_view_hash type, which will be useful to be able to use > gdb::string_view as std::unordered_map keys. > > Use it in gdb/symtab.c, to exercise it. LGTM. Thanks, Andrew > > Change-Id: Id69a466ab19a9f6620b5df8a2dd29b5cddd94c00 > --- > gdb/symtab.c | 2 +- > gdbsupport/common-utils.h | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/gdb/symtab.c b/gdb/symtab.c > index 0d342f765f2..f6ddd8e3c41 100644 > --- a/gdb/symtab.c > +++ b/gdb/symtab.c > @@ -812,7 +812,7 @@ hash_demangled_name_entry (const void *data) > const struct demangled_name_entry *e > = (const struct demangled_name_entry *) data; > > - return fast_hash (e->mangled.data (), e->mangled.length ()); > + return gdb::string_view_hash () (e->mangled); > } > > /* Equality function for the demangled name hash. */ > diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h > index fae77640666..2525d287c87 100644 > --- a/gdbsupport/common-utils.h > +++ b/gdbsupport/common-utils.h > @@ -193,4 +193,21 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0) > #endif > } > > +namespace gdb > +{ > + > +/* Hash type for gdb::string_view. > + > + Even after we switch to C++17 and dump our string_view implementation, we > + might want to keep this hash implementation if it's faster than std::hash > + for std::string_view. */ > + > +struct string_view_hash > +{ > + std::size_t operator() (gdb::string_view view) const > + { return fast_hash (view.data (), view.length ()); } > +}; > + > +} /* namespace gdb */ > + > #endif /* COMMON_COMMON_UTILS_H */ > -- > 2.38.1