From 20442dc1bc246b2f08e49ad65dbe69dcae86113e Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 20 Oct 2020 22:54:21 -0700 Subject: [PATCH] avoid extra data copying --- weed/filesys/filehandle.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 45abfcc5c..0304eebb4 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -142,8 +142,7 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f defer fh.Unlock() // write the request to volume servers - data := make([]byte, len(req.Data)) - copy(data, req.Data) + data := req.Data fh.f.entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(data)), int64(fh.f.entry.Attributes.FileSize))) glog.V(4).Infof("%v write [%d,%d) %d", fh.f.fullpath(), req.Offset, req.Offset+int64(len(req.Data)), len(req.Data))