summaryrefslogtreecommitdiff
path: root/error_buffer.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-05-02 18:21:36 +0300
committerWolfy-J <[email protected]>2019-05-02 18:21:36 +0300
commiteb8c64941cbcd30ff79b6147efd5fef42eccb648 (patch)
treebde0ceb7e7236850cfe999da7c3ffecf62b58d00 /error_buffer.go
parent34abca68708ed881c3360ee749d794b0000a3aec (diff)
miiiinor performance optimizations
Diffstat (limited to 'error_buffer.go')
-rw-r--r--error_buffer.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/error_buffer.go b/error_buffer.go
index fec789a9..becd8295 100644
--- a/error_buffer.go
+++ b/error_buffer.go
@@ -73,9 +73,8 @@ func newErrBuffer() *errBuffer {
// Listen attaches error stream even listener.
func (eb *errBuffer) Listen(l func(event int, ctx interface{})) {
eb.mu.Lock()
- defer eb.mu.Unlock()
-
eb.lsn = l
+ eb.mu.Unlock()
}
// Len returns the number of buf of the unread portion of the errBuffer;
@@ -92,10 +91,9 @@ func (eb *errBuffer) Len() int {
// needed. The return value n is the length of p; err is always nil.
func (eb *errBuffer) Write(p []byte) (int, error) {
eb.mu.Lock()
- defer eb.mu.Unlock()
-
eb.buf = append(eb.buf, p...)
eb.update <- nil
+ eb.mu.Unlock()
return len(p), nil
}