[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: zero-copy read() into Lua string?
- From: Josh Haberman <jhaberman@...>
- Date: Tue, 11 Jan 2011 07:18:48 +0000 (UTC)
Patrick Donnelly <batrick <at> batbytes.com> writes:
> If you want to push a unknown string you either use luaL_Buffer or a
> temporary userdata. Either way, you have to copy the string twice
> (once into the buffer and again when Lua pushes the actual string).
> There is no way around this. If you know the size of the string and it
> is much greater than BUFSIZ, then you should use a temporary userdata
> instead of luaL_Buffer (it is faster).
I see that this is how things are in the status quo. My question was
whether the functions I suggested could be added to Lua's C API, in
order to avoid the extra copy. Unless I am missing something they
should be easy to implement and could lead to significant efficiency
improvements for programs that call file:read() with large files.