Skip to content

Commit

Permalink
Make FileStatus.Initialize inlined in the only place where its called.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossanlop authored and carlossanlop committed May 7, 2021
1 parent 1d96271 commit 7f6cee4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -399,6 +388,12 @@ internal void RefreshCaches(ReadOnlySpan<char> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7f6cee4

Please sign in to comment.