mount: removed unnecessary byte slice allocation for reads

Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
This commit is contained in:
Anagh Kumar Baranwal 2023-04-29 18:18:21 +05:30 committed by Nick Craig-Wood
parent ae6874170f
commit d0eb884262

View File

@ -25,15 +25,13 @@ var _ fusefs.HandleReader = (*FileHandle)(nil)
func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) (err error) {
var n int
defer log.Trace(fh, "len=%d, offset=%d", req.Size, req.Offset)("read=%d, err=%v", &n, &err)
data := make([]byte, req.Size)
data := resp.Data[:req.Size]
n, err = fh.Handle.ReadAt(data, req.Offset)
resp.Data = data[:n]
if err == io.EOF {
err = nil
} else if err != nil {
return translateError(err)
}
resp.Data = data[:n]
return nil
return translateError(err)
}
// Check interface satisfied