summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v4/extended_query_builder.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-11-27 15:26:58 +0100
committerLibravatar GitHub <noreply@github.com>2021-11-27 15:26:58 +0100
commit182b4eea73881c611a0f519576aa6ad2aa6799c2 (patch)
tree230fac469690fcee8797b13585e739be148d4789 /vendor/github.com/jackc/pgx/v4/extended_query_builder.go
parentRequire confirmed email when checking oauth token (#332) (diff)
downloadgotosocial-182b4eea73881c611a0f519576aa6ad2aa6799c2.tar.xz
Update dependencies (#333)
Diffstat (limited to 'vendor/github.com/jackc/pgx/v4/extended_query_builder.go')
-rw-r--r--vendor/github.com/jackc/pgx/v4/extended_query_builder.go31
1 files changed, 12 insertions, 19 deletions
diff --git a/vendor/github.com/jackc/pgx/v4/extended_query_builder.go b/vendor/github.com/jackc/pgx/v4/extended_query_builder.go
index 09419f0d0..d06f63fd1 100644
--- a/vendor/github.com/jackc/pgx/v4/extended_query_builder.go
+++ b/vendor/github.com/jackc/pgx/v4/extended_query_builder.go
@@ -13,8 +13,6 @@ type extendedQueryBuilder struct {
paramValueBytes []byte
paramFormats []int16
resultFormats []int16
-
- resetCount int
}
func (eqb *extendedQueryBuilder) AppendParam(ci *pgtype.ConnInfo, oid uint32, arg interface{}) error {
@@ -34,32 +32,27 @@ func (eqb *extendedQueryBuilder) AppendResultFormat(f int16) {
eqb.resultFormats = append(eqb.resultFormats, f)
}
+// Reset readies eqb to build another query.
func (eqb *extendedQueryBuilder) Reset() {
eqb.paramValues = eqb.paramValues[0:0]
eqb.paramValueBytes = eqb.paramValueBytes[0:0]
eqb.paramFormats = eqb.paramFormats[0:0]
eqb.resultFormats = eqb.resultFormats[0:0]
- eqb.resetCount++
-
- // Every so often shrink our reserved memory if it is abnormally high
- if eqb.resetCount%128 == 0 {
- if cap(eqb.paramValues) > 64 {
- eqb.paramValues = make([][]byte, 0, cap(eqb.paramValues)/2)
- }
-
- if cap(eqb.paramValueBytes) > 256 {
- eqb.paramValueBytes = make([]byte, 0, cap(eqb.paramValueBytes)/2)
- }
+ if cap(eqb.paramValues) > 64 {
+ eqb.paramValues = make([][]byte, 0, 64)
+ }
- if cap(eqb.paramFormats) > 64 {
- eqb.paramFormats = make([]int16, 0, cap(eqb.paramFormats)/2)
- }
- if cap(eqb.resultFormats) > 64 {
- eqb.resultFormats = make([]int16, 0, cap(eqb.resultFormats)/2)
- }
+ if cap(eqb.paramValueBytes) > 256 {
+ eqb.paramValueBytes = make([]byte, 0, 256)
}
+ if cap(eqb.paramFormats) > 64 {
+ eqb.paramFormats = make([]int16, 0, 64)
+ }
+ if cap(eqb.resultFormats) > 64 {
+ eqb.resultFormats = make([]int16, 0, 64)
+ }
}
func (eqb *extendedQueryBuilder) encodeExtendedParamValue(ci *pgtype.ConnInfo, oid uint32, formatCode int16, arg interface{}) ([]byte, error) {