lilypond-devel
[Top][All Lists]
Advanced

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

Re: likely/unlikely macros


From: David Kastrup
Subject: Re: likely/unlikely macros
Date: Wed, 06 May 2015 20:31:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Dan Eble <address@hidden> writes:

> http://stackoverflow.com/questions/109710/likely-unlikely-macros-in-the-linux-kernel-how-do-they-work-whats-their
>
>> #define likely(x) __builtin_expect((x),1)
>> #define unlikely(x) __builtin_expect((x),0)
>
> Are there any objections to adding something like these to Lilypond?
> (I’d use static_cast<bool>(x) though.)
>
> An obvious place to use these is around the predicate in
> LY_ASSERT_TYPE where failure is unlikely.  I’m sure you can think of
> several more.

Well, I'm not all that much of a fan of these kinds of optimizations
(branch prediction on modern CPUs does part of the job) but as long as
they stay mostly within header files rather than the bulk of the code,
one might as well use them.

However, I think it would be nice if we did not stop Clang from
compiling LilyPond even though I don't know how well it currently fares
anyway.

-- 
David Kastrup



reply via email to

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