lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Fri, May 26, 2017 at 8:32 AM, François Perrad <> wrote:
    d = 5; m = 11; y = 1990
    string.format("%02d/%02d/%04d", d, m, y)                    --> "05/11/1990"

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.