Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Macros versus Inline

Author: Omid David Tabibi

Date: 08:04:53 09/27/03

Go up one level in this thread


On September 27, 2003 at 09:54:54, Russell Reagan wrote:

>On September 27, 2003 at 08:11:24, Omid David Tabibi wrote:
>
>>For a one line code, macros work much faster than inlined functions, e.g.:
>>
>>#define sgn(x)  (((x) < 0) ? -1 : (((x) > 0) ? 1 : 0))
>
>Do you only find this when you use the ternary operator? IIRC, sometimes the
>compiler can turn :? code into a branchless formula, and so that might be the
>reason that this code is faster than an inlined function that actually used an
>if statement.

In this particular case that might be the reason. But that is also the case in
many other situations in which branches are not an issue, especially commands
involving bitwise operations.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.