Return early from DistinctErrorLogger's Printf
authorbep <bjorn.erik.pedersen@gmail.com>
Fri, 3 Apr 2015 19:16:36 +0000 (21:16 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Fri, 3 Apr 2015 19:16:32 +0000 (21:16 +0200)
helpers/general.go

index cf87c04b1f0ac31c5f104be82c9aed417af0f6ba..48e7dbd01a80c63ae8900167af54516dc574def9 100644 (file)
@@ -162,11 +162,12 @@ type DistinctErrorLogger struct {
 func (l *DistinctErrorLogger) Printf(format string, v ...interface{}) {
        logStatement := fmt.Sprintf(format, v...)
        l.RLock()
-       logged := l.m[logStatement]
-       l.RUnlock()
-       if logged {
+       if l.m[logStatement] {
+               l.RUnlock()
                return
        }
+       l.RUnlock()
+
        l.Lock()
        if !l.m[logStatement] {
                jww.ERROR.Print(logStatement)