From: Chandler Carruth Date: Thu, 10 Sep 2015 06:12:31 +0000 (+0000) Subject: [ADT] Switch a bunch of places in LLVM that were doing single-character X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=6aaf0a68acfa16b2af1693b7cfcf41f77a4e2244 [ADT] Switch a bunch of places in LLVM that were doing single-character splits to actually use the single character split routine which does less work, and in a debug build is *substantially* faster. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247245 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCSectionMachO.cpp b/lib/MC/MCSectionMachO.cpp index c9f15914e4b..879c6e5ff93 100644 --- a/lib/MC/MCSectionMachO.cpp +++ b/lib/MC/MCSectionMachO.cpp @@ -177,7 +177,7 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec, // In. TAAParsed = false; SmallVector SplitSpec; - Spec.split(SplitSpec, ","); + Spec.split(SplitSpec, ','); // Remove leading and trailing whitespace. auto GetEmptyOrTrim = [&SplitSpec](size_t Idx) -> StringRef { return SplitSpec.size() > Idx ? SplitSpec[Idx].trim() : StringRef(); @@ -235,7 +235,7 @@ std::string MCSectionMachO::ParseSectionSpecifier(StringRef Spec, // In. // The attribute list is a '+' separated list of attributes. SmallVector SectionAttrs; - Attrs.split(SectionAttrs, "+", /*MaxSplit=*/-1, /*KeepEmpty=*/false); + Attrs.split(SectionAttrs, '+', /*MaxSplit=*/-1, /*KeepEmpty=*/false); for (StringRef &SectionAttr : SectionAttrs) { auto AttrDescriptorI = std::find_if( diff --git a/lib/MC/SubtargetFeature.cpp b/lib/MC/SubtargetFeature.cpp index 76574e987cb..b642f17f0e7 100644 --- a/lib/MC/SubtargetFeature.cpp +++ b/lib/MC/SubtargetFeature.cpp @@ -56,7 +56,7 @@ static inline bool isEnabled(StringRef Feature) { /// static void Split(std::vector &V, StringRef S) { SmallVector Tmp; - S.split(Tmp, ",", -1, false /* KeepEmpty */); + S.split(Tmp, ',', -1, false /* KeepEmpty */); V.assign(Tmp.begin(), Tmp.end()); } diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index cbf53493337..b80fbdb0d08 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -103,7 +103,7 @@ struct GraphSession { bool TryFindProgram(StringRef Names, std::string &ProgramPath) { raw_string_ostream Log(LogBuffer); SmallVector parts; - Names.split(parts, "|"); + Names.split(parts, '|'); for (auto Name : parts) { if (ErrorOr P = sys::findProgramByName(Name)) { ProgramPath = *P; diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp index 09f663109cb..cb1c82b0145 100644 --- a/lib/Support/Host.cpp +++ b/lib/Support/Host.cpp @@ -697,7 +697,7 @@ StringRef sys::getHostCPUName() { if (Lines[I].startswith("features")) { size_t Pos = Lines[I].find(":"); if (Pos != StringRef::npos) { - Lines[I].drop_front(Pos + 1).split(CPUFeatures, " "); + Lines[I].drop_front(Pos + 1).split(CPUFeatures, ' '); break; } } @@ -840,7 +840,7 @@ bool sys::getHostCPUFeatures(StringMap &Features) { // Look for the CPU features. for (unsigned I = 0, E = Lines.size(); I != E; ++I) if (Lines[I].startswith("Features")) { - Lines[I].split(CPUFeatures, " "); + Lines[I].split(CPUFeatures, ' '); break; } diff --git a/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp index ada3e852891..afacfa5c90f 100644 --- a/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -2283,7 +2283,7 @@ AArch64DAGToDAGISel::SelectCVTFixedPosOperand(SDValue N, SDValue &FixedPos, // into a single value to be used in the MRS/MSR instruction. static int getIntOperandFromRegisterString(StringRef RegString) { SmallVector Fields; - RegString.split(Fields, ":"); + RegString.split(Fields, ':'); if (Fields.size() == 1) return -1; diff --git a/lib/Target/ARM/ARMISelDAGToDAG.cpp b/lib/Target/ARM/ARMISelDAGToDAG.cpp index f5e12411223..5843d89b578 100644 --- a/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -3265,7 +3265,7 @@ static void getIntOperandsFromRegisterString(StringRef RegString, SelectionDAG *CurDAG, SDLoc DL, std::vector& Ops) { SmallVector Fields; - RegString.split(Fields, ":"); + RegString.split(Fields, ':'); if (Fields.size() > 1) { bool AllIntFields = true; @@ -3631,7 +3631,7 @@ SDNode *ARMDAGToDAGISel::SelectWriteRegister(SDNode *N){ } SmallVector Fields; - StringRef(SpecialReg).split(Fields, "_", 1, false); + StringRef(SpecialReg).split(Fields, '_', 1, false); std::string Reg = Fields[0].str(); StringRef Flags = Fields.size() == 2 ? Fields[1] : ""; diff --git a/lib/Target/NVPTX/NVVMReflect.cpp b/lib/Target/NVPTX/NVVMReflect.cpp index 5e375b7852e..20ab5db584d 100644 --- a/lib/Target/NVPTX/NVVMReflect.cpp +++ b/lib/Target/NVPTX/NVVMReflect.cpp @@ -109,10 +109,10 @@ void NVVMReflect::setVarMap() { for (unsigned i = 0, e = ReflectList.size(); i != e; ++i) { DEBUG(dbgs() << "Option : " << ReflectList[i] << "\n"); SmallVector NameValList; - StringRef(ReflectList[i]).split(NameValList, ","); + StringRef(ReflectList[i]).split(NameValList, ','); for (unsigned j = 0, ej = NameValList.size(); j != ej; ++j) { SmallVector NameValPair; - NameValList[j].split(NameValPair, "="); + NameValList[j].split(NameValPair, '='); assert(NameValPair.size() == 2 && "name=val expected"); std::stringstream ValStream(NameValPair[1]); int Val; diff --git a/lib/Target/SystemZ/SystemZTargetMachine.cpp b/lib/Target/SystemZ/SystemZTargetMachine.cpp index 00cbbd10a81..d011c2b6e67 100644 --- a/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -32,7 +32,7 @@ static bool UsesVectorABI(StringRef CPU, StringRef FS) { VectorABI = false; SmallVector Features; - FS.split(Features, ",", -1, false /* KeepEmpty */); + FS.split(Features, ',', -1, false /* KeepEmpty */); for (auto &Feature : Features) { if (Feature == "vector" || Feature == "+vector") VectorABI = true; diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index cfba227dbe9..a4d2ab1bfc8 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -158,7 +158,7 @@ TEST(Support, RelativePathIterator) { PathComponents ExpectedPathComponents; PathComponents ActualPathComponents; - StringRef(Path).split(ExpectedPathComponents, "/"); + StringRef(Path).split(ExpectedPathComponents, '/'); for (path::const_iterator I = path::begin(Path), E = path::end(Path); I != E; ++I) { @@ -178,7 +178,7 @@ TEST(Support, RelativePathDotIterator) { PathComponents ExpectedPathComponents; PathComponents ActualPathComponents; - StringRef(Path).split(ExpectedPathComponents, "/"); + StringRef(Path).split(ExpectedPathComponents, '/'); for (path::const_iterator I = path::begin(Path), E = path::end(Path); I != E; ++I) { @@ -198,7 +198,7 @@ TEST(Support, AbsolutePathIterator) { PathComponents ExpectedPathComponents; PathComponents ActualPathComponents; - StringRef(Path).split(ExpectedPathComponents, "/"); + StringRef(Path).split(ExpectedPathComponents, '/'); // The root path will also be a component when iterating ExpectedPathComponents[0] = "/"; @@ -221,7 +221,7 @@ TEST(Support, AbsolutePathDotIterator) { PathComponents ExpectedPathComponents; PathComponents ActualPathComponents; - StringRef(Path).split(ExpectedPathComponents, "/"); + StringRef(Path).split(ExpectedPathComponents, '/'); // The root path will also be a component when iterating ExpectedPathComponents[0] = "/";