Skip to content

Commit

Permalink
Update db.go
Browse files Browse the repository at this point in the history
Improved args Slice Handling
  • Loading branch information
KanishCanCode committed Aug 22, 2024
1 parent 9b683fc commit 9cb434f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,11 @@ func (db *pgDB) DeleteUnresolvedBatchKeys(ctx context.Context, bks []types.Batch

const columnsAffected = 2

args := make([]interface{}, len(bks)*columnsAffected)
args := make([]interface{}, 0, len(bks)*columnsAffected)
values := make([]string, len(bks))
for i, bk := range bks {
values[i] = fmt.Sprintf("($%d, $%d)", i*columnsAffected+1, i*columnsAffected+2) //nolint:mnd
args[i*columnsAffected] = bk.Number
args[i*columnsAffected+1] = bk.Hash.Hex()
args = append(args, bk.Number, bk.Hash.Hex())
}

query := fmt.Sprintf(`
Expand Down

0 comments on commit 9cb434f

Please sign in to comment.