From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id RWNDNv/n2GfNcBMAWB0awg (envelope-from ) for ; Mon, 17 Mar 2025 23:26:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1742268415; bh=x6+nZoNpmJYBtsm4XlgaTDAJWA+BADzgcdl8f2aHCrE=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AnJmUrZ+K5uZ0Zy4VKYVO2sPyJDwc/JcQSNf3jTjThaqiC8W8G8tH6Jl+ybe9CsJ3 p+1gqjGKiTonzuMMK2verovkxNgLaTX0R3Et9MpNWwa35M2VzEmgPvLZ3Iv5u4PUnB zhvALjbWtcSjhn8MxSiJNx9dt85TUSo6WHm9YDQM= Received: by simark.ca (Postfix, from userid 112) id CFF0D1E100; Mon, 17 Mar 2025 23:26:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=fbhMunxl; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=hVgxJIOY; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 76D5B1E05C for ; Mon, 17 Mar 2025 23:26:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 201D53858415 for ; Tue, 18 Mar 2025 03:26:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 201D53858415 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=fbhMunxl; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=hVgxJIOY Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6D0D03858D3C for ; Tue, 18 Mar 2025 03:26:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D0D03858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D0D03858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742268386; cv=none; b=XcEF0QxnBYzRwlbXwIP6bE9JLaPYywRD3cmK6AcjpO+9hQiJmLePmxtYttSHpzfKsWllYqp0Gbtqf5nIrfzjAIjLcZl2x3fQS2v50WU7CJaCzzX++aOoepkEzJDmfC3OQJupV75VZro8AlzJ4OAvH+q7FcEaQ6hEBscW0AzMfoU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742268386; c=relaxed/simple; bh=x6+nZoNpmJYBtsm4XlgaTDAJWA+BADzgcdl8f2aHCrE=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=DmR0/VfYnSmq9L3igTzvyzm/rxVR6ahrPOPFHRUzEccF8KDI5O0nE3Xo6voG4AIqYVwVR2j83POBibBFsyCKJcFvTAltu9sIS7yTwfAm3SrxCArG9CboC+mKgPeqjAc9/QAyco39LnwqEEpDQI/GpP3YO0Kkv9GR3lgsEdZm8p4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D0D03858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1742268386; bh=x6+nZoNpmJYBtsm4XlgaTDAJWA+BADzgcdl8f2aHCrE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=fbhMunxlBjNuXAwf2TmYexehm9gdYrfgDfKgUOYN15wDKYwJUszI8E6QDcKReSXS/ Qf85CH8DQbscMAXXAsn4sHuYxxtNoRWVCy+tHgq/7T72KmncCNIQKYaKTkJRPCZbQC 8kwTDsoS/4nTIQR2w4vtpTliiYWAlUOtzzAe7wtY= Received: by simark.ca (Postfix, from userid 112) id 243461E100; Mon, 17 Mar 2025 23:26:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1742268385; bh=x6+nZoNpmJYBtsm4XlgaTDAJWA+BADzgcdl8f2aHCrE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=hVgxJIOYjD006o/RMSkJup2GrLo3jUWHLOqs++s6ybmHX7GJufAHV+ULMc4MndFu0 EnOa7x6g2LKMmn35DSQoTIdRhtYmhbYB1b6uSxKsSX+WwJufSJpfAUPppBfygaA5eh goNrTPUauxOlzaEO7eCfx4QLhUoEBH4rFq4XDLdY= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 96C2A1E05C; Mon, 17 Mar 2025 23:26:25 -0400 (EDT) Message-ID: Date: Mon, 17 Mar 2025 23:26:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 18/19] Use gdb unordered map in tui-io.c To: Tom Tromey , gdb-patches@sourceware.org References: <20250317-replace-std-stuff-v1-0-7ba4ee88e218@tromey.com> <20250317-replace-std-stuff-v1-18-7ba4ee88e218@tromey.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20250317-replace-std-stuff-v1-18-7ba4ee88e218@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2025-03-17 22:15, Tom Tromey wrote: > This changes tui.c to use gdb::unordered_map. ui_file_style::color is > changed a little as well; operator< is no longer needed, but a simple > hash function is added. > --- > gdb/tui/tui-io.c | 37 ++++++++++++++++++++++++++++++++----- > gdb/ui-style.h | 18 ++++-------------- > 2 files changed, 36 insertions(+), 19 deletions(-) > > diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c > index 7013a543ab61f268e06e78ccad52aa5cc8419700..5d012b2e2077c8c8bd710f5694b0fcd7061b23ea 100644 > --- a/gdb/tui/tui-io.c > +++ b/gdb/tui/tui-io.c > @@ -42,7 +42,7 @@ > #include "gdbsupport/filestuff.h" > #include "completer.h" > #include "gdb_curses.h" > -#include > +#include "gdbsupport/unordered_map.h" > #include "pager.h" > #include "gdbsupport/gdb-checked-static-cast.h" > > @@ -178,9 +178,25 @@ tui_putc (char c) > update_cmdwin_start_line (); > } > > +/* Specialization of std::hash for colors. */ > + > +namespace std > +{ > +template<> struct hash > +{ > + typedef ui_file_style::color argument_type; > + typedef std::size_t result_type; > + > + result_type operator() (const argument_type &color) const noexcept > + { > + return color.hash (); > + } > +}; > +} I'm just curious to know why you decided to specialize std::hash here instead of defining a custom hash type as we do elsewhere. Simon