blachlylab / dhtslib

D bindings and OOP wrappers for htslib
MIT License
7 stars 1 forks source link

Remove GC allocation from coloration of log messages #84

Closed thewilsonator closed 3 years ago

thewilsonator commented 3 years ago

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__

jblachly commented 3 years ago

(CI failed only due to stale package list on VM)