[cfe-commits] r62426 - /cfe/trunk/lib/Lex/Lexer.cpp

Chris Lattner sabre at nondot.org
Sat Jan 17 00:30:10 PST 2009


Author: lattner
Date: Sat Jan 17 02:30:10 2009
New Revision: 62426

URL: http://llvm.org/viewvc/llvm-project?rev=62426&view=rev
Log:
simplify some lookups.

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=62426&r1=62425&r2=62426&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Sat Jan 17 02:30:10 2009
@@ -216,15 +216,15 @@
   // the token this macro expanded to.
   Loc = SM.getInstantiationLoc(Loc);
   
-  const char *StrData = SM.getCharacterData(Loc);
-  
   // TODO: this could be special cased for common tokens like identifiers, ')',
   // etc to make this faster, if it mattered.  Just look at StrData[0] to handle
   // all obviously single-char tokens.  This could use 
   // Lexer::isObviouslySimpleCharacter for example to handle identifiers or
   // something.
-  std::pair<const char *,const char *> Buffer = SM.getBufferData(Loc);
-  
+  std::pair<FileID, unsigned> LocInfo = SM.getDecomposedFileLoc(Loc);
+  std::pair<const char *,const char *> Buffer = SM.getBufferData(LocInfo.first);
+  const char *StrData = Buffer.first+LocInfo.second;
+
   // Create a langops struct and enable trigraphs.  This is sufficient for
   // measuring tokens.
   LangOptions LangOpts;





More information about the cfe-commits mailing list