hts_log is __attribute__((printf,3,4)) so we can utilise that to format the fixed length strings open_{log-level}_color, msg and close_color to avoid concatenating them (thus allocating with the GC).
N.B, ctx still requires the use of toStringz which will allocate if ctx is neither a string literal (including strings like __FUNCTION__) nor a new char[], see comment in std.string.toStringz.
Fortunately ctx is almost always either a string literal or __FUNCTION__
hts_log
is__attribute__((printf,3,4))
so we can utilise that to format the fixed length stringsopen_{log-level}_color
,msg
andclose_color
to avoid concatenating them (thus allocating with the GC).N.B,
ctx
still requires the use oftoStringz
which will allocate ifctx
is neither a string literal (including strings like__FUNCTION__
) nor a newchar[]
, see comment instd.string.toStringz
. Fortunatelyctx
is almost always either a string literal or__FUNCTION__