1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Remove the expensive BitVector::operator~().

Returning a temporary BitVector is very expensive. If you must, create
the temporary explicitly: Use BitVector(A).flip() instead of ~A.

llvm-svn: 156768
This commit is contained in:
Jakob Stoklund Olesen 2012-05-14 15:46:27 +00:00
parent f8648a8b0d
commit 184e921187
2 changed files with 4 additions and 8 deletions

View File

@ -251,11 +251,6 @@ public:
return *this;
}
// No argument flip.
BitVector operator~() const {
return BitVector(*this).flip();
}
// Indexing.
reference operator[](unsigned Idx) {
assert (Idx < Size && "Out-of-bounds Bit access.");

View File

@ -42,7 +42,8 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_FALSE(Vec.none());
EXPECT_FALSE(Vec.empty());
BitVector Inv = ~Vec;
BitVector Inv = Vec;
Inv.flip();
EXPECT_EQ(6U, Inv.count());
EXPECT_EQ(11U, Inv.size());
EXPECT_TRUE(Inv.any());
@ -52,7 +53,7 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_FALSE(Inv == Vec);
EXPECT_TRUE(Inv != Vec);
Vec = ~Vec;
Vec.flip();
EXPECT_TRUE(Inv == Vec);
EXPECT_FALSE(Inv != Vec);
@ -131,7 +132,7 @@ TEST(BitVectorTest, TrivialOperation) {
EXPECT_TRUE(Vec.none());
EXPECT_FALSE(Vec.empty());
Inv = ~BitVector();
Inv = BitVector().flip();
EXPECT_EQ(0U, Inv.count());
EXPECT_EQ(0U, Inv.size());
EXPECT_FALSE(Inv.any());