On Friday, 21 July 2017 at 21:37:39 UTC, Johan Engelen wrote:
On Friday, 21 July 2017 at 20:53:18 UTC, Walter Bright wrote:
On 7/21/2017 12:06 PM, Johan Engelen wrote:
< [...]
Another option is to use a pointer to the asan functions, like:
if (asan_fp)
(*asan_fp)(args...)
The asan_fp can then be set to NULL and there's only the
overhead of a compare/branch rather than a function call.
Well, also the load of a global variable.
I can mark the if-clause as unlikely, so the performance
difference would be small (allocation is slow already, of
course).
Quick extra note: the function pointer solution is not friendly
to LTO, whereas a weak-linking solution would easily be
optimized-out fully with LTO. So that's something to consider too.