lua-users home
lua-l archive

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


By no means an expert, but I have used C userdata as simple
string buffers with methods like append(), insert() and tostring() etc.
I was using these buffers to collect strings prior to compressing them
and then compressed them in place (with zlib). The resultant
compressed string was only occasionally then interned as a Lua string.

The buffer library was very simple to write and performed only the
functions that I needed for my app. The primary aim being to avoid
creating Lua strings before outputing them using ANSI IO (I also
added an io function that would allow me to write the userdata
buffer).

In my specific application the performance improvement was dramatic
(about 30 fold). (with Lua 5.0.2).

One of the great things about Lua is that once you have identified your
performance bottleneck then you can (usually) easily move the sluggish
piece of code to the C side.

db