[llvm-commits] [llvm] r151054 - in /llvm/trunk/lib/Support: StringExtras.cpp StringRef.cpp
Duncan Sands
baldrick at free.fr
Tue Feb 21 04:00:25 PST 2012
Author: baldrick
Date: Tue Feb 21 06:00:25 2012
New Revision: 151054
URL: http://llvm.org/viewvc/llvm-project?rev=151054&view=rev
Log:
Move the implementation of StringRef::split out of StringExtras.cpp
and into StringRef.cpp, which is where the other StringRef stuff is.
Modified:
llvm/trunk/lib/Support/StringExtras.cpp
llvm/trunk/lib/Support/StringRef.cpp
Modified: llvm/trunk/lib/Support/StringExtras.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringExtras.cpp?rev=151054&r1=151053&r2=151054&view=diff
==============================================================================
--- llvm/trunk/lib/Support/StringExtras.cpp (original)
+++ llvm/trunk/lib/Support/StringExtras.cpp Tue Feb 21 06:00:25 2012
@@ -57,24 +57,3 @@
S = getToken(S.second, Delimiters);
}
}
-
-void llvm::StringRef::split(SmallVectorImpl<StringRef> &A,
- StringRef Separators, int MaxSplit,
- bool KeepEmpty) const {
- StringRef rest = *this;
-
- // rest.data() is used to distinguish cases like "a," that splits into
- // "a" + "" and "a" that splits into "a" + 0.
- for (int splits = 0;
- rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit);
- ++splits) {
- std::pair<llvm::StringRef, llvm::StringRef> p = rest.split(Separators);
-
- if (p.first.size() != 0 || KeepEmpty)
- A.push_back(p.first);
- rest = p.second;
- }
- // If we have a tail left, add it.
- if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty))
- A.push_back(rest);
-}
Modified: llvm/trunk/lib/Support/StringRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=151054&r1=151053&r2=151054&view=diff
==============================================================================
--- llvm/trunk/lib/Support/StringRef.cpp (original)
+++ llvm/trunk/lib/Support/StringRef.cpp Tue Feb 21 06:00:25 2012
@@ -229,6 +229,27 @@
return npos;
}
+void StringRef::split(SmallVectorImpl<StringRef> &A,
+ StringRef Separators, int MaxSplit,
+ bool KeepEmpty) const {
+ StringRef rest = *this;
+
+ // rest.data() is used to distinguish cases like "a," that splits into
+ // "a" + "" and "a" that splits into "a" + 0.
+ for (int splits = 0;
+ rest.data() != NULL && (MaxSplit < 0 || splits < MaxSplit);
+ ++splits) {
+ std::pair<StringRef, StringRef> p = rest.split(Separators);
+
+ if (p.first.size() != 0 || KeepEmpty)
+ A.push_back(p.first);
+ rest = p.second;
+ }
+ // If we have a tail left, add it.
+ if (rest.data() != NULL && (rest.size() != 0 || KeepEmpty))
+ A.push_back(rest);
+}
+
//===----------------------------------------------------------------------===//
// Helpful Algorithms
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list