From: YenForYang Date: Mon, 27 Sep 2021 02:43:09 +0000 (-0500) Subject: Inlineable `(*Torrent).BytesMissing()` (#633) X-Git-Tag: v1.32.0~17 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=86fe6cc87299a457881320581e089c2524157370;p=btrtrc.git Inlineable `(*Torrent).BytesMissing()` (#633) Honestly a name like `BytesLeft` would have been more suitable, but it's too late for that I guess. --- diff --git a/torrent.go b/torrent.go index 4e272048..3981651a 100644 --- a/torrent.go +++ b/torrent.go @@ -736,10 +736,12 @@ func (t *Torrent) newMetaInfo() metainfo.MetaInfo { } } -func (t *Torrent) BytesMissing() int64 { +// Get bytes left +func (t *Torrent) BytesMissing() (n int64) { t.cl.rLock() - defer t.cl.rUnlock() - return t.bytesMissingLocked() + n = t.bytesMissingLocked() + t.cl.rUnlock() + return } func (t *Torrent) bytesMissingLocked() int64 {