From e675049aa302bf07472ae6e76ff66e6f5427eff9 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 13 Nov 2009 16:46:11 +0000 Subject: [PATCH] Remove local splitLines reimplementation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88661 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/PCHReader.cpp | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 780890de2a..ca7aa3260c 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -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 splitLines(llvm::StringRef Str, - bool KeepEmptyLines = false) { - std::vector Lines; - - while (!Str.empty()) { - std::pair 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 PCHLines = splitLines(PCHPredef); - std::vector CmdLineLines = splitLines(Left); - std::vector CmdLineLinesRight = splitLines(Right); - CmdLineLines.insert(CmdLineLines.end(), - CmdLineLinesRight.begin(), CmdLineLinesRight.end()); + llvm::SmallVector PCHLines; + PCHPredef.split(PCHLines, "\n", /*MaxSplit=*/-1, /*KeepEmpty=*/false); + + llvm::SmallVector 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::iterator ConflictPos + llvm::SmallVector::iterator ConflictPos = std::lower_bound(CmdLineLines.begin(), CmdLineLines.end(), MacroDefStart); for (; ConflictPos != CmdLineLines.end(); ++ConflictPos) { -- 2.50.1