Skip to content

Commit 2ee9fdc

Browse files
committed
perf: avoid unnecessary fixAttrs
Signed-off-by: Rueian <[email protected]>
1 parent f846b29 commit 2ee9fdc

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

node.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ func (n *FSNode) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut
223223
n.mu.RLock()
224224
if rf := n.rf; rf != nil {
225225
defer n.mu.RUnlock()
226-
defer n.fixAttr(&out.Attr, "")
227226
return rf.Getattr(ctx, out)
228227
}
229228
n.mu.RUnlock()
@@ -237,7 +236,6 @@ func (n *FSNode) Setattr(ctx context.Context, f fs.FileHandle, in *fuse.SetAttrI
237236
n.mu.Lock()
238237
defer n.mu.Unlock()
239238
if rf := n.rf; rf != nil {
240-
defer n.fixAttr(&out.Attr, "")
241239
return rf.Setattr(ctx, in, out)
242240
}
243241
if metadata := n.Metadata.(*FSNodeData); !n.IsDir() && !metadata.Ignore && in.Size < 1024 {
@@ -252,7 +250,6 @@ func (n *FSNode) Setattr(ctx context.Context, f fs.FileHandle, in *fuse.SetAttrI
252250
}
253251
defer syscall.Close(f)
254252
rf := metadata.NewRemoteFile(ptr, ino, f)
255-
defer n.fixAttr(&out.Attr, "")
256253
return rf.Setattr(ctx, in, out)
257254
}
258255
}
@@ -280,7 +277,7 @@ func (n *FSNode) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Er
280277
}
281278

282279
func (n *FSNode) fixAttr(out *fuse.Attr, name string) {
283-
if n.IsDir() || n.Metadata.(*FSNodeData).Ignore || out.Size >= 1024 {
280+
if (name == "" && n.IsDir()) || n.Metadata.(*FSNodeData).Ignore || out.Size >= 1024 {
284281
return
285282
}
286283
defer recording("fixAttr", func() string { return filepath.Join(n.path(), name) })()

0 commit comments

Comments
 (0)