[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: VM object types (was: TIOBE: Lua in the Top 20)
- From: gary ng <garyng2000@...>
- Date: Sat, 14 Jul 2007 21:04:55 -0700 (PDT)
--- Mike Pall <email@example.com> wrote:
> And ... IMHO mutable strings probably won't have
> less management
> overhead than buffers implemented with userdatas.
> Yes, I know,
> passing userdatas to C APIs expecting plain strings
> doesn't work
> right now. But this can be changed.
At the moment, I am using a relatively dirty hack. I
need a "memory buffer" which needs to be rewritten to
lots of times, sort of mutable string, see my other
post about FUSE.
I wrote a C function for the replace function. This
obviously would invalidate the hash but since it is
only used as buffer and not in other place for key,
that is fine. The only problem is that string in lua
is hashed on creation, I need to have an equivalent of
"malloc" without ending up using an existing one.
Didn't think about this initially and ("0"):rep(4096)
failed badly(of course). Now I do a
io.open("/dev/urandom"):read(4096) to create such
thing. To speed things up, I wrote a simple RC4
generator to generate the random stream faster using
/dev/urandom as the seed.
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.