1
1
mirror of https://github.com/walles/moar.git synced 2024-12-03 06:02:36 +03:00

Move code outside of a lock

This commit is contained in:
Johan Walles 2021-05-03 06:44:57 +02:00
parent 7a66c633ca
commit 9af12f451c

View File

@ -140,14 +140,15 @@ func readStream(stream io.Reader, reader *Reader, fromFilter *exec.Cmd) {
break
}
newLineString := string(completeLine)
newLine := NewLine(newLineString)
reader.lock.Lock()
if reader.replaced {
// Somebody called setText(), never mind reading the rest of this stream
reader.lock.Unlock()
break
}
newLineString := string(completeLine)
newLine := NewLine(newLineString)
reader.lines = append(reader.lines, newLine)
reader.lock.Unlock()
completeLine = completeLine[:0]