buffer: replace all ffi.new(type[1]) with cached union
Lua, which suffers from lack of ability to pass values by pointers into FFI functions, nor has an address operator '&' to take an address of integer or char or anything. Because of that a user need to either use ffi.new(type[1]) or use static buffer, but for such small allocations they are both too expensive and aggravate GC problem. Now buffer module provides preallocated basic types to use in FFI functions. The commit is motivated by one another place where ffi.new('int[1]') appeared, in SWIM module, to obtain payload size as an out parameter of a C function.
Showing
- src/lua/buffer.lua 42 additions, 0 deletionssrc/lua/buffer.lua
- src/lua/crypto.lua 6 additions, 7 deletionssrc/lua/crypto.lua
- src/lua/msgpackffi.lua 20 additions, 30 deletionssrc/lua/msgpackffi.lua
- src/lua/socket.lua 15 additions, 10 deletionssrc/lua/socket.lua
- src/lua/string.lua 2 additions, 2 deletionssrc/lua/string.lua
- test/app/buffer.result 27 additions, 0 deletionstest/app/buffer.result
- test/app/buffer.test.lua 11 additions, 0 deletionstest/app/buffer.test.lua
Loading
Please register or sign in to comment