mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
Don't iterate a dict, just grab the key
This is slow, it's a dict, not need to iterate that.
This commit is contained in:
@@ -254,13 +254,11 @@ func (am *Alertmanager) SilenceByID(id string) (models.Silence, error) {
|
||||
am.lock.RLock()
|
||||
defer am.lock.RUnlock()
|
||||
|
||||
for k, v := range am.silences {
|
||||
if k == id {
|
||||
return models.Silence(v), nil
|
||||
}
|
||||
s, found := am.silences[id]
|
||||
if !found {
|
||||
return models.Silence{}, fmt.Errorf("Silence '%s' not found", id)
|
||||
}
|
||||
|
||||
return models.Silence{}, fmt.Errorf("Silence '%s' not found", id)
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// Colors returns a copy of all color maps
|
||||
|
||||
Reference in New Issue
Block a user