Replace sprintf with string concat for speed

This code takes 5-6% of CPU time in our processes.