lua-users home
lua-l archive

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


On Tue, Aug 26, 2014 at 4:44 PM, Sean Conner <sean@conman.org> wrote:

>   Since the buffer is to be reused, and I know how I'm using the buffer,
> recvb() reads into the buffer starting at offset 0.  It then sets idx to the
> number of bytes read.  buffermeta_byte() uses idx as the length of the
> "string".

What I was confused about was that returned the byte indexed from
buf[idx + i - 1] -- this seems incorrect.  Shouldn't it just be i - 1
(up to idx at most?)

>   Okay, the names are bad, and it assumes a particular usage.  What can I
> say, it's proof-of-concept code.
>
>> Seems like immutable, pooled strings are still winning on speed though :-)
>
>   Yup.

I would love to know why that is -- if Lua's GC is keeping up with how
often the recv() (not recvb()) string is unreferenced or it's just
truly faster to create many many duplicates ~ somehow.  Maybe it's
just a stack vs heap difference -- someone told me strings are
stack-allocated in Lua but I forget how.