llvm.org GIT mirror llvm / 0057022
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156768 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 7 years ago
2 changed file(s) with 4 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
248248 BitVector &flip(unsigned Idx) {
249249 Bits[Idx / BITWORD_SIZE] ^= 1L << (Idx % BITWORD_SIZE);
250250 return *this;
251 }
252
253 // No argument flip.
254 BitVector operator~() const {
255 return BitVector(*this).flip();
256251 }
257252
258253 // Indexing.
4141 EXPECT_FALSE(Vec.none());
4242 EXPECT_FALSE(Vec.empty());
4343
44 BitVector Inv = ~Vec;
44 BitVector Inv = Vec;
45 Inv.flip();
4546 EXPECT_EQ(6U, Inv.count());
4647 EXPECT_EQ(11U, Inv.size());
4748 EXPECT_TRUE(Inv.any());
5152
5253 EXPECT_FALSE(Inv == Vec);
5354 EXPECT_TRUE(Inv != Vec);
54 Vec = ~Vec;
55 Vec.flip();
5556 EXPECT_TRUE(Inv == Vec);
5657 EXPECT_FALSE(Inv != Vec);
5758
130131 EXPECT_TRUE(Vec.none());
131132 EXPECT_FALSE(Vec.empty());
132133
133 Inv = ~BitVector();
134 Inv = BitVector().flip();
134135 EXPECT_EQ(0U, Inv.count());
135136 EXPECT_EQ(0U, Inv.size());
136137 EXPECT_FALSE(Inv.any());