On Sat, Feb 04, 2006 at 07:47:19PM +0200, Asko Kauppi wrote:
No, I think not (without patching the Lua C/API, that is).
David Given kirjoitti 2.2.2006 kello 19.44:
I'm trying to wrap a particular API function that writes a string
into a
buffer.
...
I'd like to avoid the temporary buffer. Is there any way of
persuading Lua to
allocate an *uninitialised* string of a particular length on the
stack, and
then giving me a pointer to it so I can fill in that data one's the
string's
been allocated?
Yet there is a standard workaround.
For short strings, which are 99% in most applications,
the overhead of the additional malloc by far outweights the
extra copy.
So you should see substantial speedup by providing a fixed local
buffer of 1K or so a/o using alloca, depending on platform.
best