Commit 843fec1c authored by Julien Schmidt's avatar Julien Schmidt Committed by Brad Fitzpatrick

database/sql: preallocate list slice in Drivers()

The required slice capacity is already known. Thus, preallocate a slice with the correct capacity before appending to it.

Change-Id: I45ac2c5f1701caeb3dda20451d371713ae7e7365
GitHub-Last-Rev: 2bf575be65e9a449322540270988eaf87cec4245
GitHub-Pull-Request: golang/go#34602
Reviewed-on: https://go-review.googlesource.com/c/go/+/197917Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 93136576
......@@ -64,7 +64,7 @@ func unregisterAllDrivers() {
func Drivers() []string {
driversMu.RLock()
defer driversMu.RUnlock()
var list []string
list := make([]string, 0, len(drivers))
for name := range drivers {
list = append(list, name)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment