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 | 2fd18ec43a057af248c3dd72c963c1bc32def928 (patch) | |
tree | f80817cd73e503b7a5c57e6a6a63f4a790e9455f /clang/lib | |
parent | b3ef533286e4878fa516866aae1eaa871855aebc (diff) | |
download | bcm5719-llvm-2fd18ec43a057af248c3dd72c963c1bc32def928.tar.gz bcm5719-llvm-2fd18ec43a057af248c3dd72c963c1bc32def928.zip |
PTH: Cache directory and negative 'stat' calls. This gives us a 1% performance improvement on Cocoa.h (fsyntax-only+PTH).
llvm-svn: 64490
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Lex/PTHLexer.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp index 12fe829929e..ac510af8b94 100644 --- a/clang/lib/Lex/PTHLexer.cpp +++ b/clang/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; |