From 7f6cee4c734dd147115531914cb65b567dfa6897 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Fri, 7 May 2021 16:12:36 -0700 Subject: [PATCH] Make FileStatus.Initialize inlined in the only place where its called. --- .../src/System/IO/FileStatus.Unix.cs | 17 ++++++----------- .../src/System/IO/FileSystemInfo.Unix.cs | 3 ++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs index 78456209791aef..9b92e777b514ad 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs @@ -122,17 +122,6 @@ private bool HasSymbolicLinkFlag } } - // Checks if the specified cache (lstat=_fileCache, stat=_symlinkCache) has the directory attribute set - // Only call if Refresh has been successfully called at least once, and you're - // certain the passed-in cache was successfully retrieved - private bool CacheHasDirectoryFlag(Interop.Sys.FileStatus cache) => (cache.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR; - - internal static void Initialize(ref FileStatus status, bool initiallyDirectory) - { - status.InitiallyDirectory = initiallyDirectory; - status.InvalidateCaches(); - } - // Sets the cache initialization flags to -1, which means the caches are now uninitialized internal void InvalidateCaches() { @@ -399,6 +388,12 @@ internal void RefreshCaches(ReadOnlySpan path) #endif _exists = true; + + // Checks if the specified cache (lstat=_fileCache, stat=_symlinkCache) has the directory attribute set + // Only call if Refresh has been successfully called at least once, and you're + // certain the passed-in cache was successfully retrieved + static bool CacheHasDirectoryFlag(Interop.Sys.FileStatus cache) => + (cache.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR; } // Checks if the file cache is set to -1 and refreshes it's value. diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs index d4c523a997a768..9bcae393120a8b 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs @@ -11,7 +11,8 @@ public partial class FileSystemInfo protected FileSystemInfo() { - FileStatus.Initialize(ref _fileStatus, this is DirectoryInfo); + _fileStatus.InitiallyDirectory = this is DirectoryInfo; + _fileStatus.InvalidateCaches(); } internal static FileSystemInfo Create(string fullPath, string fileName, ref FileStatus fileStatus)