From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (vps-42846194.vps.ovh.net [IPv6:2001:41d0:801:2000::2400]) by sourceware.org (Postfix) with ESMTPS id 0AF053858415 for ; Tue, 23 May 2023 09:57:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0AF053858415 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=lancelotsix.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lancelotsix.com Received: from octopus (cust120-dsl54.idnet.net [212.69.54.120]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 949D889F61; Tue, 23 May 2023 09:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=lancelotsix.com; s=2021; t=1684835833; bh=2nRz0tPg0QfM4TEMZL/Ds/OvdGjI0zMbnD7TrmnzRSo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KFx5sJq6C1/+d5tEociZmOWbWCIxpFgJr1QWHQtlQzRd0SzuhLMXCKF6wveW05Lpt s6fhDNwaWox4t3qy612zPX/ZdDQEX2fBArL9nQC5vZELNZAeXWb48tbqwuK/Elpf7S zogjlRTkSimsV1b6LsY6f8xJBUHLlW6wFgc85vw6Q4uf/OeKXd5slGmOEmux1zsM9N izX/wJzJpNXeYN+asO0bCudLb7o2IKD+OD49apVajM0cezjH8cX+EDFCzv6UGVbF8A BtexlzMktkQIIfeaLlJ2rcpCl8Dp7AoRh0rZPzYZ5ix8REzMis1XNCmCIubKBv3KKF hm6cAgAgkKbBA== Date: Tue, 23 May 2023 10:57:08 +0100 From: Lancelot SIX To: Tom de Vries Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb] Add template functions assign_set/return_if_changed Message-ID: <20230523095708.pegeoupqmirmdpoe@octopus> References: <20230523071912.2197-1-tdevries@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230523071912.2197-1-tdevries@suse.de> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Tue, 23 May 2023 09:57:13 +0000 (UTC) X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Tom, > I've initially considered using assign_return_if_changed for the rewrite: > ... > template > bool > assign_return_if_changed (T &lval, T val) > { > if (lval == val) > return false; > > lval = val; > changed = true; This line should be "return true" (only the commit comment is affected, the actual implementation is OK). > } > ... > but liked the resulting bitwise operator on the boolean a bit less: > ... > need_redraw |= assign_return_if_changed (tui_border_attrs, entry->value); > ... I think I like it a bit more (not by far though), but I guess that is just a personal preference ^_^. > > I've included it anyway, it may be the preferred choice in other cases. > Best, Lancelot.