From: Eli Zaretskii <eliz@gnu.org>
To: Evgeny Zajcev <lg.zevlg@gmail.com>
Cc: alan@idiocy.org, emacs-devel@gnu.org
Subject: Re: Hollow cursor under images
Date: Tue, 28 Jan 2020 20:16:02 +0200 [thread overview]
Message-ID: <835zgvo3a5.fsf@gnu.org> (raw)
In-Reply-To: <CAO=W_ZqpC2BrhmUTTgmSpom8EsNbK8uwNimVeTiQGKbCb-FQog@mail.gmail.com> (message from Evgeny Zajcev on Tue, 28 Jan 2020 11:46:15 +0300)
> From: Evgeny Zajcev <lg.zevlg@gmail.com>
> Date: Tue, 28 Jan 2020 11:46:15 +0300
> Cc: Alan Third <alan@idiocy.org>, emacs-devel <emacs-devel@gnu.org>
>
> > + 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.
next prev parent reply other threads:[~2020-01-28 18:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 18:14 Hollow cursor under images Evgeny Zajcev
2019-03-04 19:05 ` Eli Zaretskii
2019-03-04 20:04 ` Evgeny Zajcev
2019-03-04 20:22 ` Eli Zaretskii
2019-03-04 20:27 ` Evgeny Zajcev
2019-03-05 3:24 ` Eli Zaretskii
2019-03-04 22:36 ` Alan Third
2019-03-05 10:19 ` Evgeny Zajcev
2019-09-14 11:48 ` Evgeny Zajcev
2020-01-27 12:54 ` Evgeny Zajcev
2020-01-27 18:33 ` Eli Zaretskii
2020-01-28 8:46 ` Evgeny Zajcev
2020-01-28 18:16 ` Eli Zaretskii [this message]
2020-01-28 11:55 ` Evgeny Zajcev
2020-01-28 18:22 ` Eli Zaretskii
2020-02-03 11:24 ` Evgeny Zajcev
2020-02-07 10:12 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=835zgvo3a5.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=alan@idiocy.org \
--cc=emacs-devel@gnu.org \
--cc=lg.zevlg@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.