From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Hollow cursor under images Date: Tue, 28 Jan 2020 20:16:02 +0200 Message-ID: <835zgvo3a5.fsf@gnu.org> References: <83bm2qea01.fsf@gnu.org> <20190304223605.GA22198@breton.holly.idiocy.org> <83k15coil1.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="64204"; mail-complaints-to="usenet@ciao.gmane.io" Cc: alan@idiocy.org, emacs-devel@gnu.org To: Evgeny Zajcev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 28 20:31:38 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iwWaH-000GgS-Rf for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Jan 2020 20:31:37 +0100 Original-Received: from localhost ([::1]:36244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwWaG-00034D-TA for ged-emacs-devel@m.gmane-mx.org; Tue, 28 Jan 2020 14:31:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37406) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwVPM-0001oh-6J for emacs-devel@gnu.org; Tue, 28 Jan 2020 13:16:18 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iwVPL-0002Sq-M6; Tue, 28 Jan 2020 13:16:15 -0500 Original-Received: from [176.228.60.248] (port=3464 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iwVPE-0000Uq-3O; Tue, 28 Jan 2020 13:16:14 -0500 In-reply-to: (message from Evgeny Zajcev on Tue, 28 Jan 2020 11:46:15 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244724 Archived-At: > From: Evgeny Zajcev > Date: Tue, 28 Jan 2020 11:46:15 +0300 > Cc: Alan Third , emacs-devel > > > + if (CONSP (arg) > > + && EQ (XCAR (arg), Qbox) > > + && RANGED_FIXNUMP (0, XCDR (arg), INT_MAX)) > > + { > > + *width = XFIXNUM (XCDR (arg)); > > This calls XFIXNUM no less than 3 times. I wonder if we could tweak > the code to do that only once. > > Just for my info. Should not such tweaks be done by compiler optimizer? No value is declared as volatile, it is > pretty clear that there is no need to call XFIXNUM 3 times. You forget the unoptimized build case. And in any case, it is un-economical and inelegant, IMO, to write such code. Granted, that is a stylistic preference of mine to some extent, so if you feel strongly about that, I don't think I will fight you. > I'm afraid tweaking things in such way in source code will make code look ugly and less obvious I don't think so. Here's what I'd do in this case: if (CONSP (arg)) { Lisp_Object style = XCAR (arg); Lisp_Object lval = XCDR (arg); ptrdiff_t val = FIXNUMP (lval) ? XFIXNUM (lval) : -1; if (0 <= val && val < INT_MAX) { *width = val; if (EQ (style, Qbox)) return FILLED_BOX_CURSOR; else if (EQ (style, Qbar)) return BAR_CURSOR; else if (EQ (style, Qhbar)) return HBAR_CURSOR; } } Btw, one other advantage of the above is that you can easily display in the debugger each intermediate value used by this calculation, while stepping through the code. Again, a minor convenience, but convenience nonetheless.