d = 5; m = 11; y = 1990 string.format("%02d/%02d/%04d", d, m, y) --> "05/11/1990" string.buffer():fill'0':width(2):put(d):put'/':width(2):put(m):put'/':width(4):put(y)
You're performing a method (table) lookup and a call for each chunk of data you're formatting, is this *really* faster than a 'printf' style interface? A JIT could optimize a some of it away.
Some numbers would be helpful.
Alternatively, 'string.format' could be augmented to 'compile' each format specification into a 'program' for a trivial formatting VM and cache the result, which would be about as fast or even faster, and would not require an interface change. It could be a library that provided a replacement for string.format.