On macro vs. function (was Re: [xml] XPath extension API)

Hi Daniel, All,

This is what I'm doing for EXSLT. Code is easier to read and functions
are easier to reuse.

  Only drawback it make more function calls ... on the other hand it will
probably make the code more compact, being nicer on the cache probably
compensates the effect. And maintenance will be easier. Okay go for it !
My timings on various Intel boxes (Watcom compiler) show the function 
call overhead to be 6 to 7 cycles, 30ns on the slowest box. And I had to 
disable automatic inlining of short functions to see a difference at all.

(Processors without branch prediction or compilers without register 
argument passing may give significantly worse results)

So I would vote against the use of macros for everything which is not 
called at least once per character.

Peter Jacobi

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