From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id E58EC3857705 for ; Tue, 17 Oct 2023 09:30:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E58EC3857705 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=lancelotsix.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lancelotsix.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E58EC3857705 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=51.195.220.111 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697535029; cv=none; b=Y6Scm6xYTUsqEBf7vxy8+E9T+6tMfWfq0i5Woc4TrC5KmxPQRnlpl4+T7RPimPwboOHVKq4U47/EGNVHa7QxKwncSXS3WGW5FBGqZVW3btg83rQanw3GGTbr8qb1tMpSZhpVdOoo5FGMIlDvbBlkqoS+IvZds/7glQs68SQzgrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697535029; c=relaxed/simple; bh=Ji2eKAbkLuVKKmZ9pi9wwfOjZYjTpWmDi5QKV5UryZg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ws2TAJFy4bv2VD/97VI6AqfbGmLqpBFPqWOLNCZlNBidsPKQIZk9coetCZcNxZOJdtAE9aMEZjNIN1QGWVyLbt/60Bbj0UNcjVCNUZmKSh7y7XjIZDdLCHQCe0XgoBwbUxXPAKD/56Xzhbo6FUg60IGFwhFagP0xE8s5D8/KF4w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from octopus (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 8BE238BDD0; Tue, 17 Oct 2023 09:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lancelotsix.com; s=2021; t=1697535026; bh=Ji2eKAbkLuVKKmZ9pi9wwfOjZYjTpWmDi5QKV5UryZg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CTsDL+aPq0TE+A54tZWVax4jFE6GrZJBjNf0T/G3uXRpktdiUQp2LmpAa9xjxY6vh ovqKstBWDIMO5l0nq99Y36IMCNdLYNE+kKrnGA1T8fVG+cCLOZGjfiUi9MgfnM4IV8 wvUilk9SWmlXyjyR/r1q79ph9uyPcIMw9ZPACSKvxcC2+e+9s4hgOEgCghhf133ulE TB4mxvjRoALCuTFY6aCR3sR89Jp/ugZD934KKC3r9H0T/LiSp2+jmmqa47DINx6fAf YGsbgsNNOeHIvYxkyknsNQevHZZFmIpismIDIbtxeQsxaPfRgs510Izx3Fusll8CzK qkyngPQqSGadg== Date: Tue, 17 Oct 2023 10:30:21 +0100 From: Lancelot SIX To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 4/7] Use try_emplace in index-write.c Message-ID: <20231017093001.kecvvlg4rrdl62qe@octopus> References: <20231016230527.1820819-1-tom@tromey.com> <20231016230527.1820819-5-tom@tromey.com> <74ae9885-03ef-45f2-901e-13dd7a69de85@palves.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74ae9885-03ef-45f2-901e-13dd7a69de85@palves.net> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (lndn.lancelotsix.com [0.0.0.0]); Tue, 17 Oct 2023 09:30:26 +0000 (UTC) X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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: > > - const auto found > > - = symbol_hash_table.find (entry.cu_indices); > > - if (found != symbol_hash_table.end ()) > > + const auto &pair = symbol_hash_table.try_emplace (entry.cu_indices, > > + cpool.size ()); > > A little odd to take a const ref to the returned pair instead of taking > it by value. Better yet, C++17 gives us structured bindings, which lets us > hide the ugly pair completely and use helpful names instead of first/second: > > auto [it, ins] = symbol_hash_table.try_emplace (entry.cu_indices, > cpool.size ()); > > How about we use it here? > > Pedro Alves Hi, I find such use of structured binding to be a big help in readability. The pair is always clunky to use. Best, Lancelot.