diff options
author | Chris Lattner <sabre@nondot.org> | 2010-11-23 20:05:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-11-23 20:05:15 +0000 |
commit | d6f611198089b78e32d3a15fe8bc986204aee1aa (patch) | |
tree | d6395cf05d36ad6d8d5bba6a418b0f8396e00928 /include/clang/Basic/FileSystemStatCache.h | |
parent | 11aa4b03b054cb9d3c201bba5632241145865e29 (diff) |
simplify the cache miss handling code, eliminating CacheMissing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/FileSystemStatCache.h')
-rw-r--r-- | include/clang/Basic/FileSystemStatCache.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/include/clang/Basic/FileSystemStatCache.h b/include/clang/Basic/FileSystemStatCache.h index 7bb3706793..e9da8cf15c 100644 --- a/include/clang/Basic/FileSystemStatCache.h +++ b/include/clang/Basic/FileSystemStatCache.h @@ -32,9 +32,8 @@ public: virtual ~FileSystemStatCache() {} enum LookupResult { - CacheHitExists, //< We know the file exists and its cached stat data. - CacheHitMissing, //< We know that the file doesn't exist. - CacheMiss //< We don't know anything about the file. + CacheExists, //< We know the file exists and its cached stat data. + CacheMissing //< We know that the file doesn't exist. }; /// FileSystemStatCache::get - Get the 'stat' information for the specified @@ -42,14 +41,10 @@ public: /// the path does not exist or false if it exists. static bool get(const char *Path, struct stat &StatBuf, FileSystemStatCache *Cache) { - LookupResult R = CacheMiss; - if (Cache) - R = Cache->getStat(Path, StatBuf); + return Cache->getStat(Path, StatBuf) == CacheMissing; - if (R == FileSystemStatCache::CacheMiss) - return ::stat(Path, &StatBuf); - return R == FileSystemStatCache::CacheHitMissing; + return ::stat(Path, &StatBuf) != 0; } /// \brief Sets the next stat call cache in the chain of stat caches. @@ -73,7 +68,9 @@ protected: if (FileSystemStatCache *Next = getNextStatCache()) return Next->getStat(Path, StatBuf); - return CacheMiss; + // If we hit the end of the list of stat caches to try, just compute and + // return it without a cache. + return get(Path, StatBuf, 0) ? CacheMissing : CacheExists; } }; |