mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
Switch to smallvector. Also fix issue with using unsigend for MaxSplit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@87068 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e608819aa
commit
c78c0c99a0
@ -15,15 +15,9 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace std {
|
|
||||||
template<typename _Tp>
|
|
||||||
class allocator;
|
|
||||||
|
|
||||||
template<typename _Tp, typename _Alloc>
|
|
||||||
class vector;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
template<typename T>
|
||||||
|
class SmallVectorImpl;
|
||||||
|
|
||||||
/// StringRef - Represent a constant reference to a string, i.e. a character
|
/// StringRef - Represent a constant reference to a string, i.e. a character
|
||||||
/// array and a length, which need not be null terminated.
|
/// array and a length, which need not be null terminated.
|
||||||
@ -337,8 +331,8 @@ namespace llvm {
|
|||||||
/// \param Separator - The string to split on.
|
/// \param Separator - The string to split on.
|
||||||
/// \param MaxSplit - The maximum number of times the string is split.
|
/// \param MaxSplit - The maximum number of times the string is split.
|
||||||
/// \parm KeepEmpty - True if empty substring should be added.
|
/// \parm KeepEmpty - True if empty substring should be added.
|
||||||
void split(std::vector<StringRef, std::allocator<StringRef> > &A,
|
void split(SmallVectorImpl<StringRef> &A,
|
||||||
StringRef Separator, unsigned MaxSplit = -1,
|
StringRef Separator, int MaxSplit = -1,
|
||||||
bool KeepEmpty = true) const;
|
bool KeepEmpty = true) const;
|
||||||
|
|
||||||
/// rsplit - Split into two substrings around the last occurence of a
|
/// rsplit - Split into two substrings around the last occurence of a
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -57,12 +58,12 @@ void llvm::SplitString(const std::string &Source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void llvm::StringRef::split(std::vector<StringRef> &A,
|
void llvm::StringRef::split(SmallVectorImpl<StringRef> &A,
|
||||||
StringRef Separators, unsigned MaxSplit,
|
StringRef Separators, int MaxSplit,
|
||||||
bool KeepEmpty) const {
|
bool KeepEmpty) const {
|
||||||
StringRef rest = *this;
|
StringRef rest = *this;
|
||||||
|
|
||||||
for (unsigned splits = 0;
|
for (int splits = 0;
|
||||||
rest.size() != 0 && (MaxSplit < 0 || splits < MaxSplit);
|
rest.size() != 0 && (MaxSplit < 0 || splits < MaxSplit);
|
||||||
++splits) {
|
++splits) {
|
||||||
std::pair<llvm::StringRef, llvm::StringRef> p = rest.split(Separators);
|
std::pair<llvm::StringRef, llvm::StringRef> p = rest.split(Separators);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -111,8 +112,8 @@ TEST(StringRefTest, Split) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(StringRefTest, Split2) {
|
TEST(StringRefTest, Split2) {
|
||||||
std::vector<StringRef> parts;
|
SmallVector<StringRef, 5> parts;
|
||||||
std::vector<StringRef> expected;
|
SmallVector<StringRef, 5> expected;
|
||||||
|
|
||||||
expected.push_back("ab"); expected.push_back("c");
|
expected.push_back("ab"); expected.push_back("c");
|
||||||
StringRef(",ab,,c,").split(parts, ",", -1, false);
|
StringRef(",ab,,c,").split(parts, ",", -1, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user