Surprisingly asprintf shows up in profiling as 4.78% of the cost of a no-op re-build and 0-result returning search. Reading the GCC docs, the compiler does not know this function as a built-in. Moving to an sprintf/snprintf version has no effect; apparently GCC’s knowledge of these functions as built-ins does not help either. However going all the way to breaking the string construction into its basic elements does have an impact. This drops asprintf below 1% in this particular scenario. Overall execution time is sped up by ~3.86%.
Surprisingly
asprintf
shows up in profiling as 4.78% of the cost of a no-op re-build and 0-result returning search. Reading the GCC docs, the compiler does not know this function as a built-in. Moving to ansprintf
/snprintf
version has no effect; apparently GCC’s knowledge of these functions as built-ins does not help either. However going all the way to breaking the string construction into its basic elements does have an impact. This dropsasprintf
below 1% in this particular scenario. Overall execution time is sped up by ~3.86%.