]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Inlineable `(*Torrent).BytesMissing()` (#633)
authorYenForYang <YenForYang@users.noreply.github.com>
Mon, 27 Sep 2021 02:43:09 +0000 (21:43 -0500)
committerGitHub <noreply@github.com>
Mon, 27 Sep 2021 02:43:09 +0000 (12:43 +1000)
Honestly a name like `BytesLeft` would have been more suitable, but it's too late for that I guess.

torrent.go

index 4e272048e08546d6d0c5828daf8830004be03e37..3981651a614f247cf36756043d481f85482979bf 100644 (file)
@@ -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 {