[cfe-commits] r88661 - /cfe/trunk/lib/Frontend/PCHReader.cpp

Daniel Dunbar daniel at zuster.org
Fri Nov 13 08:46:11 PST 2009


Author: ddunbar
Date: Fri Nov 13 10:46:11 2009
New Revision: 88661

URL: http://llvm.org/viewvc/llvm-project?rev=88661&view=rev
Log:
Remove local splitLines reimplementation.

Modified:
    cfe/trunk/lib/Frontend/PCHReader.cpp

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=88661&r1=88660&r2=88661&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Fri Nov 13 10:46:11 2009
@@ -132,29 +132,6 @@
   return true;
 }
 
-/// \brief Split the given string into a vector of lines, eliminating
-/// any empty lines in the process.
-///
-/// \param Str the string to split.
-/// \param Len the length of Str.
-/// \param KeepEmptyLines true if empty lines should be included
-/// \returns a vector of lines, with the line endings removed
-static std::vector<llvm::StringRef> splitLines(llvm::StringRef Str,
-                                               bool KeepEmptyLines = false) {
-  std::vector<llvm::StringRef> Lines;
-
-  while (!Str.empty()) {
-    std::pair<llvm::StringRef, llvm::StringRef> split = Str.split('\n');
-
-    if (KeepEmptyLines || !split.first.empty())
-      Lines.push_back(split.first);
-
-    Str = split.second;
-  }
-
-  return Lines;
-}
-
 bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef,
                                         FileID PCHBufferID,
                                         llvm::StringRef OriginalFileName,
@@ -181,11 +158,12 @@
 
   // The predefines buffers are different. Determine what the differences are,
   // and whether they require us to reject the PCH file.
-  std::vector<llvm::StringRef> PCHLines = splitLines(PCHPredef);
-  std::vector<llvm::StringRef> CmdLineLines = splitLines(Left);
-  std::vector<llvm::StringRef> CmdLineLinesRight = splitLines(Right);
-  CmdLineLines.insert(CmdLineLines.end(),
-                      CmdLineLinesRight.begin(), CmdLineLinesRight.end());
+  llvm::SmallVector<llvm::StringRef, 8> PCHLines;
+  PCHPredef.split(PCHLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+
+  llvm::SmallVector<llvm::StringRef, 8> CmdLineLines;
+  Left.split(CmdLineLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+  Right.split(CmdLineLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
   // Sort both sets of predefined buffer lines, since we allow some extra
   // definitions and they may appear at any point in the output.
@@ -221,7 +199,7 @@
     // command line.
     std::string MacroDefStart = "#define " + MacroName.str();
     std::string::size_type MacroDefLen = MacroDefStart.size();
-    std::vector<llvm::StringRef>::iterator ConflictPos
+    llvm::SmallVector<llvm::StringRef, 8>::iterator ConflictPos
       = std::lower_bound(CmdLineLines.begin(), CmdLineLines.end(),
                          MacroDefStart);
     for (; ConflictPos != CmdLineLines.end(); ++ConflictPos) {





More information about the cfe-commits mailing list