]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Just use File.WriteAt for mmap file io WriteAt
authorMatt Joiner <anacrolix@gmail.com>
Thu, 21 Aug 2025 04:25:48 +0000 (14:25 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 21 Aug 2025 04:25:48 +0000 (14:25 +1000)
Also remove WriteTo for shared handle, it doesn't make sense without a pos.

storage/file-io-mmap.go

index ec060712d3be0265fb6e21d302c659e6312bfbde..b11dca840abb64cf109a892b4dea35b15c92891e 100644 (file)
@@ -163,14 +163,9 @@ type mmapSharedFileHandle struct {
 }
 
 func (m *mmapSharedFileHandle) WriteAt(p []byte, off int64) (n int, err error) {
-       //fmt.Println("mmapSharedFileHandle.WriteAt", off, len(p), len(m.f.m))
-       n = copy(m.f.m[off:], p)
-       return
-}
-
-func (m *mmapSharedFileHandle) WriteTo(w io.Writer) (n int64, err error) {
-       //TODO implement me
-       panic("implement me")
+       // It's not actually worth the hassle to write using mmap here since the caller provided the
+       // buffer already.
+       return m.f.f.WriteAt(p, off)
 }
 
 func (m *mmapSharedFileHandle) ReadAt(p []byte, off int64) (n int, err error) {