Exactly! Lua is very slow on string concats of any kind. string.format is definitely a lot faster, but if performance is an issue you wouldn't want to use cecho() anyways but use setFgColor() and echo() directly.tsuujin wrote:No, I spent a good deal of time looking this up a while back. string.format ends up being a lot faster than concatenations, because the lua engine creates an entirely new memory address for each concat. So if you concat three times, you end up with four separate concatenation functions and the memory sits until the GC clears it up. String.format, however, is done outside of the lua engine on the C side and doesn't suffer this problem.demonnic wrote:In this case, "better" is a matter of opinion. Either one works just fine. Some folks prefer concat, some folks prefer string.format . I imagine a lot of it has to do with your coding roots.
There are problems with the GC and concat when used rapidly (like a combat system tends to do).
Though for most users performance is never actually an issue they have to care about simply because their systems don't have very high performance requirements.