replace snprintf with handwritten code for 20% speedup on insert