Skip to content

Commit

Permalink
Remove anynil.NormalizeSlice
Browse files Browse the repository at this point in the history
anynil.Is was already being called in all paths that
anynil.NormalizeSlice was used.
  • Loading branch information
jackc committed May 19, 2024
1 parent c1075bf commit 6ea2d24
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 14 deletions.
2 changes: 0 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"
"time"

"github.com/jackc/pgx/v5/internal/anynil"
"github.com/jackc/pgx/v5/internal/sanitize"
"github.com/jackc/pgx/v5/internal/stmtcache"
"github.com/jackc/pgx/v5/pgconn"
Expand Down Expand Up @@ -755,7 +754,6 @@ optionLoop:
}

c.eqb.reset()
anynil.NormalizeSlice(args)
rows := c.getRows(ctx, sql, args)

var err error
Expand Down
2 changes: 0 additions & 2 deletions extended_query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type ExtendedQueryBuilder struct {
func (eqb *ExtendedQueryBuilder) Build(m *pgtype.Map, sd *pgconn.StatementDescription, args []any) error {
eqb.reset()

anynil.NormalizeSlice(args)

if sd == nil {
for i := range args {
err := eqb.appendParam(m, 0, pgtype.TextFormatCode, args[i])
Expand Down
10 changes: 0 additions & 10 deletions internal/anynil/anynil.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,3 @@ func Is(value any) bool {
return false
}
}

// NormalizeSlice converts all typed nils (e.g. []byte(nil)) in s into untyped nils. Other values are unmodified. s is
// mutated in place.
func NormalizeSlice(s []any) {
for i := range s {
if Is(s[i]) {
s[i] = nil
}
}
}

0 comments on commit 6ea2d24

Please sign in to comment.