Skip to content

Commit

Permalink
Merge pull request prometheus#2021 from prometheus/beorn7/storage
Browse files Browse the repository at this point in the history
Avoid `defer` in seriesMap.get
  • Loading branch information
fabxc authored Sep 22, 2016
2 parents 2ee00b4 + ca98382 commit 71b3322
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions storage/local/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ func (sm *seriesMap) length() int {
// semantics as the native Go map.
func (sm *seriesMap) get(fp model.Fingerprint) (s *memorySeries, ok bool) {
sm.mtx.RLock()
defer sm.mtx.RUnlock()

s, ok = sm.m[fp]
// Note that the RUnlock is not done via defer for performance reasons.
// TODO(beorn7): Once https://github.com/golang/go/issues/14939 is
// fixed, revert to the usual defer idiom.
sm.mtx.RUnlock()
return
}

Expand Down

0 comments on commit 71b3322

Please sign in to comment.