[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using __builtin_expect (likely/unlikely macros)

From: Paul Eggert
Subject: Re: Using __builtin_expect (likely/unlikely macros)
Date: Sat, 20 Apr 2019 12:13:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Eli Zaretskii wrote:
In this case the patch not only improved performance, it also made
the code smaller and in my opinion more readable: the total source
code size shrank by 1775 bytes.
I meant code in C, not the produced machine code

Yes, that's what I meant too. That is, the patch made the C code shorter.

I'm not sure how do you see that the code became more readable

It's more readable to me partly because the common case is shorter, e.g.:

-static _Noreturn void module_abort (const char *format, ...)
+static AVOID module_abort (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);

and partly because the unusual case is more obviously unusual. For example, in:

-static _Noreturn void
+static AVOID
 x_connection_closed (Display *dpy, const char *error_message, bool ioerror)
-static _Noreturn int
+static _Noreturn ATTRIBUTE_COLD int
 x_io_error_quitter (Display *display)

the x_connection_closed closed is obviously typical (it uses the now-common "AVOID"), whereas the x_io_error_quitter is obviously atypical (one normally doesn't see ATTRIBUTE_COLD in .c files), and this lets the reader more-easily see that x_io_error_quitter (a) returns 'int' and (b) never returns anything, which makes it even more of an oddball than the usual AVOID functions are.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]