mirror of https://github.com/aldy505/bob.git
perf: migrate bytes.Buffer to strings.Builder for micro optimization
This commit is contained in:
parent
f1008bdf4a
commit
3e4261df9e
|
@ -1,7 +1,6 @@
|
|||
package bob
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
|
@ -205,7 +204,7 @@ func (d *createData) ToSql() (sqlStr string, args []interface{}, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
sql := &bytes.Buffer{}
|
||||
var sql strings.Builder
|
||||
|
||||
sql.WriteString("CREATE TABLE ")
|
||||
|
||||
|
|
4
has.go
4
has.go
|
@ -1,8 +1,8 @@
|
|||
package bob
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/lann/builder"
|
||||
)
|
||||
|
@ -50,7 +50,7 @@ func (h HasBuilder) ToSql() (string, []interface{}, error) {
|
|||
|
||||
// ToSql returns 3 variables filled out with the correct values based on bindings, etc.
|
||||
func (d *hasData) ToSql() (sqlStr string, args []interface{}, err error) {
|
||||
sql := &bytes.Buffer{}
|
||||
var sql strings.Builder
|
||||
if d.Name == "" {
|
||||
err = errors.New("has statement should have a table name")
|
||||
return
|
||||
|
|
34
internal.go
34
internal.go
|
@ -14,21 +14,21 @@ func createArgs(keys ...interface{}) []interface{} {
|
|||
}
|
||||
|
||||
// isIn checks if an array have a value
|
||||
func isIn(arr []string, value string) bool {
|
||||
for _, item := range arr {
|
||||
if item == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
// func isIn(arr []string, value string) bool {
|
||||
// for _, item := range arr {
|
||||
// if item == value {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
|
||||
// findPosition search for value position on an array
|
||||
func findPosition(arr []string, value string) int {
|
||||
for i, item := range arr {
|
||||
if item == value {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
// // findPosition search for value position on an array
|
||||
// func findPosition(arr []string, value string) int {
|
||||
// for i, item := range arr {
|
||||
// if item == value {
|
||||
// return i
|
||||
// }
|
||||
// }
|
||||
// return -1
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue