]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Inlineable (*reader).SetReadAhead and (*reader).Close (#594)
authorYenForYang <YenForYang@users.noreply.github.com>
Tue, 14 Sep 2021 04:05:37 +0000 (23:05 -0500)
committerGitHub <noreply@github.com>
Tue, 14 Sep 2021 04:05:37 +0000 (14:05 +1000)
Small fixes that prevent inlining of public functions

reader.go

index 53833e37038075d9f0fbef4880eca4418957155e..3b407ce34f823f247cfbd2f789b13678c1b52bab 100644 (file)
--- a/reader.go
+++ b/reader.go
@@ -70,10 +70,10 @@ func (r *reader) SetNonResponsive() {
 
 func (r *reader) SetReadahead(readahead int64) {
        r.mu.Lock()
-       defer r.mu.Unlock()
        r.readahead = readahead
        r.readaheadFunc = nil
        r.posChanged()
+       r.mu.Unlock()
 }
 
 // How many bytes are available to read. Max is the most we could require.
@@ -248,8 +248,8 @@ func (r *reader) readOnceAt(ctx context.Context, b []byte, pos int64) (n int, er
 // Hodor
 func (r *reader) Close() error {
        r.t.cl.lock()
-       defer r.t.cl.unlock()
        r.t.deleteReader(r)
+       r.t.cl.unlock()
        return nil
 }