Optimize calls.

This commit is contained in:
Nuno Cruces
2023-05-02 01:05:41 +01:00
parent 40457721d7
commit 59f79e8e74
2 changed files with 6 additions and 6 deletions

View File

@@ -79,7 +79,7 @@ type module struct {
mod api.Module
vfs io.Closer
api sqliteAPI
arg []uint64
arg [8]uint64
}
func newModule(mod api.Module) (m *module, err error) {
@@ -205,14 +205,14 @@ func (m *module) error(rc uint64, handle uint32, sql ...string) error {
}
func (m *module) call(fn api.Function, params ...uint64) []uint64 {
m.arg = append(m.arg[:0], params...)
r, err := fn.Call(m.ctx, m.arg...)
copy(m.arg[:], params)
err := fn.CallWithStack(m.ctx, m.arg[:])
if err != nil {
// The module closed or panicked; release resources.
m.vfs.Close()
panic(err)
}
return r
return m.arg[:]
}
func (m *module) free(ptr uint32) {

View File

@@ -26,14 +26,14 @@ func TestConn_error_OOM(t *testing.T) {
t.Error("want panic")
}
func TestConn_call_nil(t *testing.T) {
func TestConn_call_closed(t *testing.T) {
t.Parallel()
m, err := instantiateModule()
if err != nil {
t.Fatal(err)
}
defer m.close()
m.close()
defer func() { _ = recover() }()
m.call(m.api.free)