sysfs: return st instead of accepting it (#1261)
This returns stat as a value instead of a pointer param. This is both more efficient and faster. It is also more efficient than returning a pointer to a stat. Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -100,16 +100,16 @@ func WriteTestFiles(tmpDir string) (err error) {
|
||||
}
|
||||
|
||||
// os.Stat uses GetFileInformationByHandle internally.
|
||||
var stat platform.Stat_t
|
||||
if err = platform.Stat(path, &stat); err != nil {
|
||||
var st platform.Stat_t
|
||||
if st, err = platform.Stat(path); err != nil {
|
||||
return err
|
||||
}
|
||||
if stat.Mtim == info.ModTime().UnixNano() {
|
||||
if st.Mtim == info.ModTime().UnixNano() {
|
||||
return nil // synced!
|
||||
}
|
||||
|
||||
// Otherwise, we need to sync the timestamps.
|
||||
return os.Chtimes(path, time.Unix(0, stat.Atim), time.Unix(0, stat.Mtim))
|
||||
return os.Chtimes(path, time.Unix(0, st.Atim), time.Unix(0, st.Mtim))
|
||||
})
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user