From: YenForYang Date: Wed, 15 Sep 2021 00:14:28 +0000 (-0500) Subject: Inlineable `(*Torrent).PieceState()` (#621) X-Git-Tag: v1.32.0~56 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=542970b961870017e91abc0156b9d2f431d57fcb;p=btrtrc.git Inlineable `(*Torrent).PieceState()` (#621) --- diff --git a/t.go b/t.go index aae6812b..02d62979 100644 --- a/t.go +++ b/t.go @@ -74,10 +74,11 @@ func (t *Torrent) PieceStateRuns() (runs PieceStateRuns) { return } -func (t *Torrent) PieceState(piece pieceIndex) PieceState { +func (t *Torrent) PieceState(piece pieceIndex) (ps PieceState) { t.cl.rLock() - defer t.cl.rUnlock() - return t.pieceState(piece) + ps = t.pieceState(piece) + t.cl.rUnlock() + return } // The number of pieces in the torrent. This requires that the info has been