diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-13 22:07:44 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-13 22:07:44 +0000 |
commit | ad6ce5cb0e3b5dd853d2b1e337797a6fc1091e21 (patch) | |
tree | 419097e0d13699d8076bd32d897548101b5b5584 /lib/Lex/PTHLexer.cpp | |
parent | f161d4155f51328da08d4a28233d5ca9ce5b998a (diff) |
PTH: Cache directory and negative 'stat' calls. This gives us a 1% performance improvement on Cocoa.h (fsyntax-only+PTH).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r-- | lib/Lex/PTHLexer.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index 12fe829929..ac510af8b9 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -808,15 +808,17 @@ public: static data_type ReadData(const internal_key_type& k, const unsigned char* d, unsigned) { - if (k.first == 0x1 /* File */) { - d += 4 * 2; // Skip the first 2 words. + + if (k.first /* File or Directory */) { + if (k.first == 0x1 /* File */) d += 4 * 2; // Skip the first 2 words. ino_t ino = (ino_t) ReadUnalignedLE32(d); dev_t dev = (dev_t) ReadUnalignedLE32(d); mode_t mode = (mode_t) ReadUnalignedLE16(d); time_t mtime = (time_t) ReadUnalignedLE64(d); return data_type(ino, dev, mode, mtime, (off_t) ReadUnalignedLE64(d)); } - + + // Negative stat. Don't read anything. return data_type(); } }; @@ -841,6 +843,10 @@ public: if (I == Cache.end()) return ::stat(path, buf); const PTHStatData& Data = *I; + + if (!Data.hasStat) + return 1; + buf->st_ino = Data.ino; buf->st_dev = Data.dev; buf->st_mtime = Data.mtime; |