Commit cdc1ffac authored by gwenn's avatar gwenn

Avoids copying some data.

parent 77e10c5a
...@@ -11,7 +11,9 @@ import ( ...@@ -11,7 +11,9 @@ import (
"io" "io"
"log" "log"
"os" "os"
"reflect"
"time" "time"
"unsafe"
) )
func init() { func init() {
...@@ -57,12 +59,15 @@ func (d *Driver) Open(name string) (driver.Conn, error) { ...@@ -57,12 +59,15 @@ func (d *Driver) Open(name string) (driver.Conn, error) {
// PRAGMA schema_version may be used to detect when the database schema is altered // PRAGMA schema_version may be used to detect when the database schema is altered
func (c *connImpl) Exec(query string, args []driver.Value) (driver.Result, error) { func (c *connImpl) Exec(query string, args []driver.Value) (driver.Result, error) {
// http://code.google.com/p/go-wiki/wiki/InterfaceSlice // https://code.google.com/p/go-wiki/wiki/cgo#Turning_C_arrays_into_Go_slices
tmp := make([]interface{}, len(args)) var iargs []interface{}
for i, arg := range args { if len(args) > 0 {
tmp[i] = arg h := (*reflect.SliceHeader)(unsafe.Pointer(&iargs))
} h.Data = uintptr(unsafe.Pointer(&args[0]))
if err := c.c.Exec(query, tmp...); err != nil { h.Len = len(args)
h.Cap = cap(args)
}
if err := c.c.Exec(query, iargs...); err != nil {
return nil, err return nil, err
} }
return c, nil // FIXME RowAffected/noRows return c, nil // FIXME RowAffected/noRows
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment