mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 19:54:10 -06:00
chore: preallocate slices where we have a good idea of requirements (#91596)
* chore: preallocate slices where we have a good idea of requirements * pr feedback
This commit is contained in:
parent
9b652612bd
commit
a117b090cf
@ -540,7 +540,7 @@ func postPath(pre string, v config.AlertmanagerAPIVersion) string {
|
||||
// AlertmanagerFromGroup extracts a list of alertmanagers from a target group
|
||||
// and an associated AlertmanagerConfig.
|
||||
func AlertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig) ([]alertmanager, []alertmanager, error) {
|
||||
var res []alertmanager
|
||||
res := make([]alertmanager, 0, len(tg.Targets))
|
||||
var droppedAlertManagers []alertmanager
|
||||
|
||||
for _, tlset := range tg.Targets {
|
||||
|
@ -1096,10 +1096,10 @@ func (db *postgres) GetTables() ([]*core.Table, error) {
|
||||
}
|
||||
|
||||
func getIndexColName(indexdef string) []string {
|
||||
var colNames []string
|
||||
|
||||
cs := strings.Split(indexdef, "(")
|
||||
for _, v := range strings.Split(strings.Split(cs[1], ")")[0], ",") {
|
||||
splitNames := strings.Split(strings.Split(cs[1], ")")[0], ",")
|
||||
colNames := make([]string, 0, len(splitNames))
|
||||
for _, v := range splitNames {
|
||||
colNames = append(colNames, strings.Split(strings.TrimLeft(v, " "), " ")[0])
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ func eraseAny(value string, strToErase ...string) string {
|
||||
if len(strToErase) == 0 {
|
||||
return value
|
||||
}
|
||||
var replaceSeq []string
|
||||
replaceSeq := make([]string, 0, len(strToErase)*2)
|
||||
for _, s := range strToErase {
|
||||
replaceSeq = append(replaceSeq, s, "")
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ func (statement *Statement) genUniqueSQL() []string {
|
||||
}
|
||||
|
||||
func (statement *Statement) genDelIndexSQL() []string {
|
||||
var sqls []string
|
||||
sqls := make([]string, 0, len(statement.RefTable.Indexes))
|
||||
tbName := statement.TableName()
|
||||
idxPrefixName := strings.Replace(tbName, `"`, "", -1)
|
||||
idxPrefixName = strings.Replace(idxPrefixName, `.`, "_", -1)
|
||||
|
Loading…
Reference in New Issue
Block a user