forked from OSchip/llvm-project
parent
8ae8fd08ff
commit
e08c540e68
|
@ -53,7 +53,10 @@ protected:
|
|||
: TheTable(nullptr),
|
||||
// Initialize the map with zero buckets to allocation.
|
||||
NumBuckets(0), NumItems(0), NumTombstones(0), ItemSize(itemSize) {}
|
||||
StringMapImpl(StringMapImpl &&RHS) : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets), NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones), ItemSize(RHS.ItemSize) {
|
||||
StringMapImpl(StringMapImpl &&RHS)
|
||||
: TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets),
|
||||
NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones),
|
||||
ItemSize(RHS.ItemSize) {
|
||||
RHS.TheTable = nullptr;
|
||||
RHS.NumBuckets = 0;
|
||||
RHS.NumItems = 0;
|
||||
|
@ -115,7 +118,7 @@ public:
|
|||
explicit StringMapEntry(unsigned strLen)
|
||||
: StringMapEntryBase(strLen), second() {}
|
||||
StringMapEntry(unsigned strLen, ValueTy V)
|
||||
: StringMapEntryBase(strLen), second(std::move(V)) {}
|
||||
: StringMapEntryBase(strLen), second(std::move(V)) {}
|
||||
|
||||
StringRef getKey() const {
|
||||
return StringRef(getKeyData(), getKeyLength());
|
||||
|
@ -351,7 +354,7 @@ public:
|
|||
return *static_cast<MapEntryTy*>(Bucket);
|
||||
|
||||
MapEntryTy *NewItem =
|
||||
MapEntryTy::Create(Key.begin(), Key.end(), Allocator, std::move(Val));
|
||||
MapEntryTy::Create(Key.begin(), Key.end(), Allocator, std::move(Val));
|
||||
|
||||
if (Bucket == getTombstoneVal())
|
||||
--NumTombstones;
|
||||
|
|
|
@ -221,17 +221,18 @@ TEST_F(StringMapTest, NonDefaultConstructable) {
|
|||
struct MoveOnly {
|
||||
int i;
|
||||
MoveOnly(int i) : i(i) {}
|
||||
MoveOnly(MoveOnly&&) = default;
|
||||
MoveOnly(const MoveOnly&) = delete;
|
||||
MoveOnly &operator=(MoveOnly&&) = default;
|
||||
MoveOnly &operator=(const MoveOnly&) = delete;
|
||||
MoveOnly(MoveOnly &&) = default;
|
||||
MoveOnly(const MoveOnly &) = delete;
|
||||
MoveOnly &operator=(MoveOnly &&) = default;
|
||||
MoveOnly &operator=(const MoveOnly &) = delete;
|
||||
};
|
||||
|
||||
TEST_F(StringMapTest, MoveOnlyKey) {
|
||||
StringMap<MoveOnly> t;
|
||||
t.GetOrCreateValue("Test", MoveOnly(42));
|
||||
StringRef Key = "Test";
|
||||
StringMapEntry<MoveOnly>::Create(Key.begin(), Key.end(), MoveOnly(42))->Destroy();
|
||||
StringMapEntry<MoveOnly>::Create(Key.begin(), Key.end(), MoveOnly(42))
|
||||
->Destroy();
|
||||
}
|
||||
|
||||
TEST_F(StringMapTest, MoveConstruct) {
|
||||
|
@ -259,24 +260,23 @@ TEST_F(StringMapTest, MoveAssignment) {
|
|||
struct Countable {
|
||||
int &InstanceCount;
|
||||
int Number;
|
||||
Countable(int Number, int &InstanceCount) :InstanceCount(InstanceCount), Number(Number) {
|
||||
Countable(int Number, int &InstanceCount)
|
||||
: InstanceCount(InstanceCount), Number(Number) {
|
||||
++InstanceCount;
|
||||
}
|
||||
Countable(Countable &&C) : InstanceCount(C.InstanceCount), Number(C.Number) {
|
||||
++InstanceCount;
|
||||
C.Number = -1;
|
||||
}
|
||||
Countable(const Countable &C) : InstanceCount(C.InstanceCount), Number(C.Number) {
|
||||
Countable(const Countable &C)
|
||||
: InstanceCount(C.InstanceCount), Number(C.Number) {
|
||||
++InstanceCount;
|
||||
}
|
||||
Countable &operator=(Countable C) {
|
||||
Number = C.Number;
|
||||
return *this;
|
||||
}
|
||||
~Countable() {
|
||||
--InstanceCount;
|
||||
}
|
||||
|
||||
~Countable() { --InstanceCount; }
|
||||
};
|
||||
|
||||
TEST_F(StringMapTest, MoveDtor) {
|
||||
|
|
Loading…
Reference in New Issue