Avoid `defer` in seriesMap.get

This is related to https://github.com/golang/go/issues/14939 .
It's probably the only occurrence where it matters.
This commit is contained in:
beorn7 2016-09-22 17:49:22 +02:00
parent 2ee00b4461
commit ca98382943
1 changed files with 4 additions and 2 deletions

View File

@ -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
}