From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6QwFM8NksWh8HQ8AWB0awg (envelope-from ) for ; Fri, 29 Aug 2025 04:28:51 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u7gRhRFL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FSH4eHIQ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=g2gw4nH4; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=T6QOQMIo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CAD931E04C; Fri, 29 Aug 2025 04:28:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 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 062131E043 for ; Fri, 29 Aug 2025 04:28:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 610D93857BA3 for ; Fri, 29 Aug 2025 08:28:50 +0000 (GMT) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id F0B443858C66 for ; Fri, 29 Aug 2025 08:28:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0B443858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F0B443858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756456110; cv=none; b=ZMceJsdRvIE3eRBCTtAVrMLV44BPXj7Xv8jsSoVf3D32fUesTxm8PIZetgiE5OF1VkWeZP8juTQ8Bsb7cMdIZXvQLGGRdoK/HFpGYG2z+TFRnSuqnrB64s3Pm310SEJ/GmdKOqDvGHV7TCiWVNJ0ePluc/xUHtWOA4aYOlb1ki4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756456110; c=relaxed/simple; bh=aJTJZT14LzACcvVkwS/ITS3yigdPom70U07rQq7blPM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=YrcmIFXpHL0FQB0Zp0SLwGdl7ZpgkdHMq4cRMQB5d52zse7GqOuQKDRN9ucCFoxGKR/fsRHaDJG0M8QdZ3dJQaX3/xqmdk3Nw+bSSqMwGO1Kui9ldDT/yEX++NO3kyc+V/20x8lPFv3zHJiTQ7EMDVE2dSNuD85Ps4f/feI5nBg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0B443858C66 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u7gRhRFL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=FSH4eHIQ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=g2gw4nH4; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=T6QOQMIo Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F17B433C79; Fri, 29 Aug 2025 08:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1756456107; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Stb6AZhKglc//QRnZvDQtFUtREYmml2YsykdClmGO4k=; b=u7gRhRFL/GYoiE49Ld5V7RVsYjR7n5niL+LorU60gNUnwLeVaIbjF8A7V6rQ+97v8kIx6k d2S2fN21uBP9s/BeyY8UPC3gzG2jG0kyUQiKY+75CWLmNMX1/tedvSTVHTQrsUwinO43Mm V0YjeN0WpibfzNL0kjU9OrBrK8Qs5zU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1756456107; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Stb6AZhKglc//QRnZvDQtFUtREYmml2YsykdClmGO4k=; b=FSH4eHIQrHCz4+t//SCJvLe5WmLa7nTiFWTm077/UdAu559Mdx5OTntn/QPURTaqpIfhWa rf9H7VEVgkzVJcAQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1756456106; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Stb6AZhKglc//QRnZvDQtFUtREYmml2YsykdClmGO4k=; b=g2gw4nH4bM+dafr/T2BOPnhEt7cjok/+vCw2F0loHTfO1482ufGNMX1zBMA/gTq1Ge4rE6 Oam56M5Zl9/qz1mSywvx2rKetk3Cl+apzWHDkR4ksEyJ7USpzPj4n43rI9L5WC56ZDpZtn 9Cztey8t9hEyd58MJsZfEXT6An38Hf4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1756456106; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Stb6AZhKglc//QRnZvDQtFUtREYmml2YsykdClmGO4k=; b=T6QOQMIocx50fKuSxAuKNQZYUXLcK+hlbqwX3/hSHF6qp5kW7esPCd9NyuAskRxwC2pGLf SwtqqaYd0tPiYODA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D74D713A54; Fri, 29 Aug 2025 08:28:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 32ZQM6pksWitHQAAD6G6ig (envelope-from ); Fri, 29 Aug 2025 08:28:26 +0000 Message-ID: Date: Fri, 29 Aug 2025 10:28:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/5] [gdb] Make addrmap_mutable::insert_empty return bool To: Tom Tromey , Simon Marchi Cc: gdb-patches@sourceware.org References: <20250821133114.24091-1-tdevries@suse.de> <20250821133114.24091-3-tdevries@suse.de> <87a53rkx5v.fsf@tromey.com> <87frdbj7ws.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <87frdbj7ws.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,simark.ca:email] 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 8/29/25 02:20, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Tom> + if (addrmap_node_value (n)) > Tom> + { > Tom> + /* Already mapped. */ > Tom> + full_range = false; > Tom> + continue; > Tom> + } > Tom> + > Tom> + addrmap_node_set_value (n, obj); > >>> FWIW, I still think that they way I wrote is is much better. My >>> opinion is based on this coding standard rule ( >>> https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code >>> ). > > I don't think we should use LLVM's coding standards. Hi Tom, I realize I'm probably not going to convince you, so all I'm trying to do here is to better make my argument, since I have not done a good job sofar. I'm not advocating that we should use LLVM's coding standards, regardless. I'm saying that we could use some of them if they make sense and don't conflict with the existing coding standard. Reading the rule was a light-bulb moment for me, and has shaped my opinion on how to write code. Agreed, it can be argued that the rule doesn't apply here because the if-else branches are too small. It also says "Aim to reduce indentation where possible when it doesn’t make it more difficult to understand the code". Of course it's highly debatable how to fill this in. For me, it makes sense to look at the impact of the branches. To illustrate my point, I think it makes sense to do: ... if (...) a = b; else c = d; ... but not ... if (...) a = b; else exec ("rm -Rf /") ... In the latter case, I'd rather write: ... if (!...) { a = b; continue; } exec ("rm -Rf /"); ... to have the most impactful statement stand out both by less indentation, and by having it standalone rather than as part of an if/else. And I feel the same applies to: ... if (...) { /* Don't do something and make a note of it. */ } else { /* Do something. */ } ... > Particularly so > now that I've worked on LLVM this last year. > > Simon> I also like early returns and early continue in loops. It tells me: you > Simon> don't need to think about that case for the rest of the function loop. > > In this particular case the two branches are single lines. FWIW, one branch is one line, the other 4 lines: ... if (addrmap_node_value (n)) { /* Already mapped. */ full_range = false; } else addrmap_node_set_value (n, obj); ... Thanks, - Tom > Using a continue here seems more confusing for that reason -- it's just > more to process here. > > I get it for longer loops, at least situationally. > > Tom