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:
@@ -97,9 +97,8 @@ func (e externalAlertmanagerToDatasources) Exec(sess *xorm.Session, mg *migrator
|
||||
}
|
||||
|
||||
func removeDuplicates(strs []string) []string {
|
||||
var res []string
|
||||
found := map[string]bool{}
|
||||
|
||||
found := make(map[string]bool, len(strs))
|
||||
res := make([]string, 0, len(strs))
|
||||
for _, str := range strs {
|
||||
if found[str] {
|
||||
continue
|
||||
|
||||
@@ -435,8 +435,10 @@ func (f *accessControlDashboardPermissionFilter) nestedFoldersSelectors(permSele
|
||||
}
|
||||
|
||||
func getAllowedUIDs(action string, user identity.Requester, scopePrefix string) []any {
|
||||
var args []any
|
||||
for _, uidScope := range user.GetPermissions()[action] {
|
||||
uidScopes := user.GetPermissions()[action]
|
||||
|
||||
args := make([]any, 0, len(uidScopes))
|
||||
for _, uidScope := range uidScopes {
|
||||
if !strings.HasPrefix(uidScope, scopePrefix) {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user