Merge pull request #1901 from simonpasquier/refactor-marker-count

types: refactor *memMarker.Count method
This commit is contained in:
stuart nelson 2019-05-27 17:36:43 +02:00 committed by GitHub
commit b783cf8e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 9 deletions

View File

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