]> granicus.if.org Git - clang/commitdiff
Remove local splitLines reimplementation.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 13 Nov 2009 16:46:11 +0000 (16:46 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 13 Nov 2009 16:46:11 +0000 (16:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88661 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PCHReader.cpp

index 780890de2abf46f7af793e7f83daaab24112554f..ca7aa3260c62f105f926fbc0d8088d1c6d83d5b4 100644 (file)
@@ -132,29 +132,6 @@ bool PCHValidator::ReadTargetTriple(llvm::StringRef Triple) {
   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 @@ bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef,
 
   // 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 @@ bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef,
     // 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) {