mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 09:42:06 +08:00
chore(perf): Pre-allocate where possible (enable prealloc linter) (#88952)
* chore(perf): Pre-allocate where possible (enable prealloc linter) Signed-off-by: Dave Henderson <dave.henderson@grafana.com> * fix TestAlertManagers_buildRedactedAMs Signed-off-by: Dave Henderson <dave.henderson@grafana.com> * prealloc a slice that appeared after rebase Signed-off-by: Dave Henderson <dave.henderson@grafana.com> --------- Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
@ -84,15 +84,16 @@ func newFlowTestQueries(allJsonBytes []byte) ([]backend.DataQuery, error) {
|
||||
return nil, fmt.Errorf("error unmarshaling query-json: %w", err)
|
||||
}
|
||||
|
||||
var queries []backend.DataQuery
|
||||
|
||||
for _, jsonBytes := range jsonBytesArray {
|
||||
queries := make([]backend.DataQuery, len(jsonBytesArray))
|
||||
for i, jsonBytes := range jsonBytesArray {
|
||||
// we need to extract some fields from the json-array
|
||||
var jsonInfo queryDataTestQueryJSON
|
||||
|
||||
err = json.Unmarshal(jsonBytes, &jsonInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// we setup the DataQuery, with values loaded from the json
|
||||
query := backend.DataQuery{
|
||||
RefID: jsonInfo.RefID,
|
||||
@ -101,7 +102,8 @@ func newFlowTestQueries(allJsonBytes []byte) ([]backend.DataQuery, error) {
|
||||
TimeRange: timeRange,
|
||||
JSON: jsonBytes,
|
||||
}
|
||||
queries = append(queries, query)
|
||||
|
||||
queries[i] = query
|
||||
}
|
||||
return queries, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user