[cfe-commits] r39091 - in /cfe/cfe/trunk: Lex/Pragma.cpp Lex/Preprocessor.cpp include/clang/Lex/Preprocessor.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:27:27 PDT 2007


Author: sabre
Date: Wed Jul 11 11:27:27 2007
New Revision: 39091

URL: http://llvm.org/viewvc/llvm-project?rev=39091&view=rev
Log:
Make Preprocessor::LookupFile take a character range instead of a string.
This avoids some copying in its clients.

Modified:
    cfe/cfe/trunk/Lex/Pragma.cpp
    cfe/cfe/trunk/Lex/Preprocessor.cpp
    cfe/cfe/trunk/include/clang/Lex/Preprocessor.h

Modified: cfe/cfe/trunk/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Pragma.cpp?rev=39091&r1=39090&r2=39091&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Pragma.cpp (original)
+++ cfe/cfe/trunk/Lex/Pragma.cpp Wed Jul 11 11:27:27 2007
@@ -255,12 +255,12 @@
   // Find out whether the filename is <x> or "x".
   bool isAngled = Filename[0] == '<';
   
-  // Remove the quotes.
-  Filename = std::string(Filename.begin()+1, Filename.end()-1);
-  
   // Search include directories for this file.
   const DirectoryLookup *CurDir;
-  const FileEntry *File = LookupFile(Filename, isAngled, 0, CurDir);
+
+  // Remove the quotes.
+  const FileEntry *File = LookupFile(&Filename[1], &Filename[Filename.size()-1],
+                                     isAngled, 0, CurDir);
   if (File == 0)
     return Diag(FilenameTok, diag::err_pp_file_not_found);
   

Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=39091&r1=39090&r2=39091&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:27:27 2007
@@ -251,7 +251,8 @@
 /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
 /// return null on failure.  isAngled indicates whether the file reference is
 /// for system #include's or not (i.e. using <> instead of "").
-const FileEntry *Preprocessor::LookupFile(const std::string &Filename,
+const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
+                                          const char *FilenameEnd,
                                           bool isAngled,
                                           const DirectoryLookup *FromDir,
                                           const DirectoryLookup *&CurDir) {
@@ -263,9 +264,6 @@
     CurFileEnt = SourceMgr.getFileEntryForFileID(TheFileID);
   }
   
-  const char *FilenameStart = &Filename[0];
-  const char *FilenameEnd = FilenameStart+Filename.size();
-  
   // Do a standard file entry lookup.
   CurDir = CurDirLookup;
   const FileEntry *FE =
@@ -1502,12 +1500,11 @@
   // Find out whether the filename is <x> or "x".
   bool isAngled = Filename[0] == '<';
   
-  // Remove the quotes.
-  Filename = std::string(Filename.begin()+1, Filename.end()-1);
-  
   // Search include directories.
   const DirectoryLookup *CurDir;
-  const FileEntry *File = LookupFile(Filename, isAngled, LookupFrom, CurDir);
+  // Remove the quotes from the filename.
+  const FileEntry *File = LookupFile(&Filename[1], &Filename[Filename.size()-1],
+                                     isAngled, LookupFrom, CurDir);
   if (File == 0)
     return Diag(FilenameTok, diag::err_pp_file_not_found);
   

Modified: cfe/cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=39091&r1=39090&r2=39091&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/cfe/trunk/include/clang/Lex/Preprocessor.h Wed Jul 11 11:27:27 2007
@@ -406,8 +406,8 @@
   /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
   /// return null on failure.  isAngled indicates whether the file reference is
   /// for system #include's or not (i.e. using <> instead of "").
-  const FileEntry *LookupFile(const std::string &Filename, bool isAngled,
-                              const DirectoryLookup *FromDir,
+  const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd,
+                              bool isAngled, const DirectoryLookup *FromDir,
                               const DirectoryLookup *&CurDir);
     
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list