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%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61364 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/CacheTokens.cpp b/Driver/CacheTokens.cpp
index d8c9249..c97b225 100644
--- a/Driver/CacheTokens.cpp
+++ b/Driver/CacheTokens.cpp
@@ -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 {