Commit 6f753a8e authored by gwenn's avatar gwenn

Minor optim.

parent edac256f
...@@ -376,8 +376,8 @@ type sqliteFunction struct { ...@@ -376,8 +376,8 @@ type sqliteFunction struct {
final FinalFunction final FinalFunction
d DestroyDataFunction d DestroyDataFunction
pApp interface{} pApp interface{}
scalarCtxs map[*ScalarContext]bool scalarCtxs map[*ScalarContext]struct{}
aggrCtxs map[*AggregateContext]bool aggrCtxs map[*AggregateContext]struct{}
} }
//export goXAuxDataDestroy //export goXAuxDataDestroy
...@@ -400,7 +400,7 @@ func goXFunc(scp, udfp, ctxp unsafe.Pointer, argc int, argv unsafe.Pointer) { ...@@ -400,7 +400,7 @@ func goXFunc(scp, udfp, ctxp unsafe.Pointer, argc int, argv unsafe.Pointer) {
c.udf = udf c.udf = udf
C.goSqlite3SetAuxdata((*C.sqlite3_context)(c.sc), 0, unsafe.Pointer(c)) C.goSqlite3SetAuxdata((*C.sqlite3_context)(c.sc), 0, unsafe.Pointer(c))
// To make sure it is not cged // To make sure it is not cged
udf.scalarCtxs[c] = true udf.scalarCtxs[c] = struct{}{}
} }
c.argv = (**C.sqlite3_value)(argv) c.argv = (**C.sqlite3_value)(argv)
udf.scalar(c, argc) udf.scalar(c, argc)
...@@ -420,7 +420,7 @@ func goXStep(scp, udfp unsafe.Pointer, argc int, argv unsafe.Pointer) { ...@@ -420,7 +420,7 @@ func goXStep(scp, udfp unsafe.Pointer, argc int, argv unsafe.Pointer) {
c.sc = (*Context)(scp) c.sc = (*Context)(scp)
*(*unsafe.Pointer)(cp) = unsafe.Pointer(c) *(*unsafe.Pointer)(cp) = unsafe.Pointer(c)
// To make sure it is not cged // To make sure it is not cged
udf.aggrCtxs[c] = true udf.aggrCtxs[c] = struct{}{}
} else { } else {
c = (*AggregateContext)(p) c = (*AggregateContext)(p)
} }
...@@ -476,7 +476,7 @@ func (c *Conn) CreateScalarFunction(functionName string, nArg int, deterministic ...@@ -476,7 +476,7 @@ func (c *Conn) CreateScalarFunction(functionName string, nArg int, deterministic
fmt.Sprintf("<Conn.CreateScalarFunction(%q)", functionName)) fmt.Sprintf("<Conn.CreateScalarFunction(%q)", functionName))
} }
// To make sure it is not gced, keep a reference in the connection. // To make sure it is not gced, keep a reference in the connection.
udf := &sqliteFunction{f, nil, nil, d, pApp, make(map[*ScalarContext]bool), nil} udf := &sqliteFunction{f, nil, nil, d, pApp, make(map[*ScalarContext]struct{}), nil}
if len(c.udfs) == 0 { if len(c.udfs) == 0 {
c.udfs = make(map[string]*sqliteFunction) c.udfs = make(map[string]*sqliteFunction)
} }
...@@ -500,7 +500,7 @@ func (c *Conn) CreateAggregateFunction(functionName string, nArg int, pApp inter ...@@ -500,7 +500,7 @@ func (c *Conn) CreateAggregateFunction(functionName string, nArg int, pApp inter
fmt.Sprintf("<Conn.CreateAggregateFunction(%q)", functionName)) fmt.Sprintf("<Conn.CreateAggregateFunction(%q)", functionName))
} }
// To make sure it is not gced, keep a reference in the connection. // To make sure it is not gced, keep a reference in the connection.
udf := &sqliteFunction{nil, step, final, d, pApp, nil, make(map[*AggregateContext]bool)} udf := &sqliteFunction{nil, step, final, d, pApp, nil, make(map[*AggregateContext]struct{})}
if len(c.udfs) == 0 { if len(c.udfs) == 0 {
c.udfs = make(map[string]*sqliteFunction) c.udfs = make(map[string]*sqliteFunction)
} }
......
...@@ -22,13 +22,13 @@ type sqliteModule struct { ...@@ -22,13 +22,13 @@ type sqliteModule struct {
c *Conn c *Conn
name string name string
module Module module Module
vts map[*sqliteVTab]bool vts map[*sqliteVTab]struct{}
} }
type sqliteVTab struct { type sqliteVTab struct {
module *sqliteModule module *sqliteModule
vTab VTab vTab VTab
vtcs map[*sqliteVTabCursor]bool vtcs map[*sqliteVTabCursor]struct{}
} }
type sqliteVTabCursor struct { type sqliteVTabCursor struct {
...@@ -65,9 +65,9 @@ func goMInit(db, pClientData unsafe.Pointer, argc int, argv **C.char, pzErr **C. ...@@ -65,9 +65,9 @@ func goMInit(db, pClientData unsafe.Pointer, argc int, argv **C.char, pzErr **C.
vt := &sqliteVTab{m, vTab, nil} vt := &sqliteVTab{m, vTab, nil}
// prevents 'vt' from being gced // prevents 'vt' from being gced
if m.vts == nil { if m.vts == nil {
m.vts = make(map[*sqliteVTab]bool) m.vts = make(map[*sqliteVTab]struct{})
} }
m.vts[vt] = true m.vts[vt] = struct{}{}
*pzErr = nil *pzErr = nil
return unsafe.Pointer(vt) return unsafe.Pointer(vt)
} }
...@@ -101,9 +101,9 @@ func goVOpen(pVTab unsafe.Pointer, pzErr **C.char) unsafe.Pointer { ...@@ -101,9 +101,9 @@ func goVOpen(pVTab unsafe.Pointer, pzErr **C.char) unsafe.Pointer {
// prevents 'vt' from being gced // prevents 'vt' from being gced
vtc := &sqliteVTabCursor{vt, vTabCursor} vtc := &sqliteVTabCursor{vt, vTabCursor}
if vt.vtcs == nil { if vt.vtcs == nil {
vt.vtcs = make(map[*sqliteVTabCursor]bool) vt.vtcs = make(map[*sqliteVTabCursor]struct{})
} }
vt.vtcs[vtc] = true vt.vtcs[vtc] = struct{}{}
*pzErr = nil *pzErr = nil
return unsafe.Pointer(vtc) return unsafe.Pointer(vtc)
} }
......
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