[cfe-commits] r61364 - in /cfe/trunk: Driver/CacheTokens.cpp lib/Lex/PTHLexer.cpp
Ted Kremenek
kremenek at apple.com
Mon Dec 22 18:52:13 PST 2008
Author: kremenek
Date: Mon Dec 22 20:52:12 2008
New Revision: 61364
URL: http://llvm.org/viewvc/llvm-project?rev=61364&view=rev
Log:
PTH:
- Encode the token length with 2 bytes instead of 4.
- This reduces the size of the .pth file for Cocoa.h by 12%.
- This speeds up PTH time (-Eonly) on Cocoa.h by 1.6%.
Modified:
cfe/trunk/Driver/CacheTokens.cpp
cfe/trunk/lib/Lex/PTHLexer.cpp
Modified: cfe/trunk/Driver/CacheTokens.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/CacheTokens.cpp?rev=61364&r1=61363&r2=61364&view=diff
==============================================================================
--- cfe/trunk/Driver/CacheTokens.cpp (original)
+++ cfe/trunk/Driver/CacheTokens.cpp Mon Dec 22 20:52:12 2008
@@ -30,6 +30,10 @@
typedef llvm::DenseMap<const FileEntry*,std::pair<Offset,Offset> > PCHMap;
typedef llvm::DenseMap<const IdentifierInfo*,uint32_t> IDMap;
+static void Emit8(llvm::raw_ostream& Out, uint32_t V) {
+ Out << (unsigned char)(V);
+}
+
static void Emit32(llvm::raw_ostream& Out, uint32_t V) {
Out << (unsigned char)(V);
Out << (unsigned char)(V >> 8);
@@ -37,8 +41,10 @@
Out << (unsigned char)(V >> 24);
}
-static void Emit8(llvm::raw_ostream& Out, uint32_t V) {
+static void Emit16(llvm::raw_ostream& Out, uint32_t V) {
Out << (unsigned char)(V);
+ Out << (unsigned char)(V >> 8);
+ assert((V >> 16) == 0);
}
static void EmitBuf(llvm::raw_ostream& Out, const char* I, const char* E) {
@@ -69,7 +75,7 @@
Emit8(Out, T.getFlags());
Emit32(Out, ResolveID(IM, idcount, T.getIdentifierInfo()));
Emit32(Out, SMgr.getFullFilePos(T.getLocation()));
- Emit32(Out, T.getLength());
+ Emit16(Out, T.getLength());
}
struct IDData {
Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=61364&r1=61363&r2=61364&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Mon Dec 22 20:52:12 2008
@@ -26,7 +26,7 @@
using namespace clang;
-#define DISK_TOKEN_SIZE (2+3*4)
+#define DISK_TOKEN_SIZE (2+4+4+2)
//===----------------------------------------------------------------------===//
// Utility methods for reading from the mmap'ed PTH file.
@@ -79,9 +79,7 @@
| (((uint32_t) CurPtrShadow[9]) << 24);
uint32_t Len = ((uint32_t) CurPtrShadow[10])
- | (((uint32_t) CurPtrShadow[11]) << 8)
- | (((uint32_t) CurPtrShadow[12]) << 16)
- | (((uint32_t) CurPtrShadow[13]) << 24);
+ | (((uint32_t) CurPtrShadow[11]) << 8);
CurPtr = (const char*) (CurPtrShadow + DISK_TOKEN_SIZE);
More information about the cfe-commits
mailing list