[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: zero-copy read() into Lua string?
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 11 Jan 2011 04:37:35 -0500
On Tue, Jan 11, 2011 at 2:18 AM, Josh Haberman <email@example.com> wrote:
> 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.
- Patrick Donnelly