types: refactor *memMarker.Count method

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2019-05-24 13:36:01 +02:00
parent 588b4dd17b
commit 27e99e9e35
1 changed files with 8 additions and 9 deletions

View File

@ -128,19 +128,18 @@ func (m *memMarker) registerMetrics(r prometheus.Registerer) {
// Count implements Marker. // Count implements Marker.
func (m *memMarker) Count(states ...AlertState) int { func (m *memMarker) Count(states ...AlertState) int {
count := 0
m.mtx.RLock() m.mtx.RLock()
defer m.mtx.RUnlock() defer m.mtx.RUnlock()
if len(states) == 0 { if len(states) == 0 {
count = len(m.m) return len(m.m)
} else { }
for _, status := range m.m {
for _, state := range states { var count int
if status.State == state { for _, status := range m.m {
count++ for _, state := range states {
} if status.State == state {
count++
} }
} }
} }