mirror of
https://github.com/jroimartin/gocui.git
synced 2025-05-08 19:29:28 +08:00
use defer rather than call unlock at end of function
This commit is contained in:
parent
3cd3a41702
commit
9f871b6b9d
3
view.go
3
view.go
@ -228,6 +228,7 @@ func (v *View) Origin() (x, y int) {
|
||||
func (v *View) Write(p []byte) (n int, err error) {
|
||||
v.tainted = true
|
||||
v.writeMutex.Lock()
|
||||
defer v.writeMutex.Unlock()
|
||||
|
||||
for _, ch := range bytes.Runes(p) {
|
||||
switch ch {
|
||||
@ -254,7 +255,7 @@ func (v *View) Write(p []byte) (n int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
v.writeMutex.Unlock()
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user