lua-users home
lua-l archive

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


The module I presented at the Lua Workshop 08, now with MIT License:

   http://topaz.cx/xstring/xstring-1.0.1.tar.gz

Abstract:

   This Lua module provides the abstraction "xstring", or "external string".

   An external string is a userdata object that represents a string (more
   generally, a memory area) not owned by any Lua instance.  It solves the
   problem of performance loss and memory usage caused by Lua's taking an
   internal copy of all strings before working with them.

   The xstring implementation is based on two C structures: the xsbuf and the
   xstr.  An xsbuf is a structure with a reference count, a pointer, and a
   size.  An xstr is the structure inside the userdata of the Lua xstring
   objects, which refers to a portion of an xsbuf.

   The xsbuf and xstr structures are both quite small and simple; it is
   therefore extremely inexpensive to create and destroy them.  Their only
   complexity is actually an efficiency hack: each xstr actually represents a
   *substring* of a given memory area (usually, however, this is the substring
   of the whole).  This allows for sub-xstring creation without forcing
   conversion to an interned Lua string.

Share & Enjoy!
-- 
Chip Salzenberg <chip@pobox.com>