Skip to content

Commit

Permalink
vtorc: pre-alloc underlying array in sqlutils.RowToArray
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
  • Loading branch information
timvaillancourt committed Nov 12, 2024
1 parent a925663 commit 38302d3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions go/vt/external/golib/sqlutils/sqlutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ func GetSQLiteDB(dbFile string) (*sql.DB, bool, error) {
// RowToArray is a convenience function, typically not called directly, which maps a
// single read database row into a NullString
func RowToArray(rows *sql.Rows, columns []string) ([]CellData, error) {
buff := make([]any, len(columns))
data := make([]CellData, len(columns))
numColumns := len(columns)
buff := make([]any, numColumns, numColumns)

Check failure on line 167 in go/vt/external/golib/sqlutils/sqlutils.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

S1019: should use make([]any, numColumns) instead (gosimple)

Check failure on line 167 in go/vt/external/golib/sqlutils/sqlutils.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

S1019: should use make([]any, numColumns) instead (gosimple)
data := make([]CellData, numColumns, numColumns)

Check failure on line 168 in go/vt/external/golib/sqlutils/sqlutils.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

S1019: should use make([]CellData, numColumns) instead (gosimple)

Check failure on line 168 in go/vt/external/golib/sqlutils/sqlutils.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

S1019: should use make([]CellData, numColumns) instead (gosimple)
for i := range buff {
buff[i] = data[i].NullString()
}
Expand Down

0 comments on commit 38302d3

Please sign in to comment.