Skip to content

Commit

Permalink
Speed up encoding for int64, float64, and bool
Browse files Browse the repository at this point in the history
  • Loading branch information
erykwalder authored and johto committed Apr 18, 2015
1 parent 62de2aa commit 8910d1c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) []byte {
switch v := x.(type) {
case int64:
return []byte(fmt.Sprintf("%d", v))
return strconv.AppendInt(nil, v, 10)
case float64:
return []byte(fmt.Sprintf("%.17f", v))
return strconv.AppendFloat(nil, v, 'f', -1, 64)
case []byte:
if pgtypOid == oid.T_bytea {
return encodeBytea(parameterStatus.serverVersion, v)
Expand All @@ -33,7 +33,7 @@ func encode(parameterStatus *parameterStatus, x interface{}, pgtypOid oid.Oid) [

return []byte(v)
case bool:
return []byte(fmt.Sprintf("%t", v))
return strconv.AppendBool(nil, v)
case time.Time:
return formatTs(v)

Expand Down

0 comments on commit 8910d1c

Please sign in to comment.