mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: Use Readdirnames to count fds for FDUsage
Readdir already calls Readdirnames, but continues to allocate os.FileInfo with Lstat for each result.
This commit is contained in:
parent
4b6a0eea49
commit
be70400fb5
@ -33,13 +33,12 @@ func FDUsage() (uint64, error) {
|
||||
}
|
||||
|
||||
// countFiles reads the directory named by dirname and returns the count.
|
||||
// This is same as stdlib "io/ioutil.ReadDir" but without sorting.
|
||||
func countFiles(dirname string) (uint64, error) {
|
||||
f, err := os.Open(dirname)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
list, err := f.Readdir(-1)
|
||||
list, err := f.Readdirnames(-1)
|
||||
f.Close()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user