From 57b4e78b0f04b16996dc15925e22875a2ead274c Mon Sep 17 00:00:00 2001 From: YenForYang Date: Tue, 14 Sep 2021 07:11:35 -0500 Subject: [PATCH] Inlineable `(*File).BytesCompleted()` (#612) --- file.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/file.go b/file.go index e2720e5a..35fe9239 100644 --- a/file.go +++ b/file.go @@ -44,13 +44,14 @@ func (f *File) Length() int64 { // Number of bytes of the entire file we have completed. This is the sum of // completed pieces, and dirtied chunks of incomplete pieces. -func (f *File) BytesCompleted() int64 { +func (f *File) BytesCompleted() (n int64) { f.t.cl.rLock() - defer f.t.cl.rUnlock() - return f.bytesCompleted() + n = f.bytesCompletedLocked() + f.t.cl.rUnlock() + return } -func (f *File) bytesCompleted() int64 { +func (f *File) bytesCompletedLocked() int64 { return f.length - f.bytesLeft() } -- 2.48.1