mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 21:50:22 +03:00
use Access() instead of Lstat() for frequent use (#11911)
using Lstat() is causing tiny memory allocations, that are usually wasted and never used, instead we can simply uses Access() call that does 0 memory allocations.
This commit is contained in:
@@ -25,8 +25,17 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func access(name string) error {
|
||||
if err := unix.Access(name, unix.R_OK|unix.W_OK); err != nil {
|
||||
return &os.PathError{Op: "lstat", Path: name, Err: err}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The buffer must be at least a block long.
|
||||
// refer https://github.com/golang/go/issues/24015
|
||||
const blockSize = 8 << 10 // 8192
|
||||
|
||||
Reference in New Issue
Block a user