My point was that all the really fast versions here use pre-allocated buffer under the cover to store the string and grow the buffer some amount only, if needed. Go's string builder does that as well as GString. Not sure about the default allocated buffer sizes, but it makes sense to minimize allocations and copying. My current 8th version (not posted yet) uses buffer to store ascii string bytes and that buffer can dynamically grow, if needed.
Well, yes. You shouldn't assign to a char*, for example, unless you've allocated enouch space for it.
I think the wording is what is confusing things; what I mean by pre-allocated buffer is a STATIC buffer, for example char a[65535]. You can't call "realloc' on that, so you have to create a new string if you want to 'add' to it.
So now the question becomes, what is a 'fair' initial buffer size. 'g_string_new(NULL)', which is what I used in the GLIB submission, creates an initial buffer that is 2 bytes in size (according to the source code for GString). I could have passed an initial size, like the 65K above, but I wanted to test how the default operated from a performance standpoint.
Anyway, I'm looking forward to seeing how you choose to implement this, Jalih.
AIR.