ffi optimization