mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Give SmallPtrSet move semantics when we have R-value references.
Somehow, this ADT got missed which is moderately terrifying considering the efficiency of move for it. The code to implement move semantics for it is pretty horrible currently but was written to reasonably closely match the rest of the code. Unittests that cover both copying and moving (at a basic level) added. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195239 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -71,6 +71,55 @@ TEST(SmallPtrSetTest, GrowthTest) {
|
||||
EXPECT_EQ(1,buf[i]);
|
||||
}
|
||||
|
||||
TEST(SmallPtrSetTest, CopyAndMoveTest) {
|
||||
int buf[8];
|
||||
for (int i = 0; i < 8; ++i)
|
||||
buf[i] = 0;
|
||||
|
||||
SmallPtrSet<int *, 4> s1;
|
||||
s1.insert(&buf[0]);
|
||||
s1.insert(&buf[1]);
|
||||
s1.insert(&buf[2]);
|
||||
s1.insert(&buf[3]);
|
||||
EXPECT_EQ(4U, s1.size());
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if (i < 4)
|
||||
EXPECT_TRUE(s1.count(&buf[i]));
|
||||
else
|
||||
EXPECT_FALSE(s1.count(&buf[i]));
|
||||
|
||||
SmallPtrSet<int *, 4> s2(s1);
|
||||
EXPECT_EQ(4U, s2.size());
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if (i < 4)
|
||||
EXPECT_TRUE(s2.count(&buf[i]));
|
||||
else
|
||||
EXPECT_FALSE(s2.count(&buf[i]));
|
||||
|
||||
s1 = s2;
|
||||
EXPECT_EQ(4U, s1.size());
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if (i < 4)
|
||||
EXPECT_TRUE(s1.count(&buf[i]));
|
||||
else
|
||||
EXPECT_FALSE(s1.count(&buf[i]));
|
||||
|
||||
SmallPtrSet<int *, 4> s3(llvm_move(s1));
|
||||
EXPECT_EQ(4U, s3.size());
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if (i < 4)
|
||||
EXPECT_TRUE(s3.count(&buf[i]));
|
||||
else
|
||||
EXPECT_FALSE(s3.count(&buf[i]));
|
||||
|
||||
s1 = llvm_move(s3);
|
||||
EXPECT_EQ(4U, s1.size());
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if (i < 4)
|
||||
EXPECT_TRUE(s1.count(&buf[i]));
|
||||
else
|
||||
EXPECT_FALSE(s1.count(&buf[i]));
|
||||
}
|
||||
|
||||
TEST(SmallPtrSetTest, SwapTest) {
|
||||
int buf[10];
|
||||
|
Reference in New Issue
Block a user