diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-01 18:52:53 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-01 18:52:53 +0000 |
commit | 693e3ee0c2d2a2cb6f691222694a788dd595c108 (patch) | |
tree | 392fd35385e220c279874b3e360dfab3365f92a3 /include/llvm/ADT/SmallBitVector.h | |
parent | 2b76473929add5f48242416ce4409b0a17e662ca (diff) |
Provide move semantics for (Small)BitVector.
CodeGen makes a lot of BitVector copies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallBitVector.h')
-rw-r--r-- | include/llvm/ADT/SmallBitVector.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/ADT/SmallBitVector.h b/include/llvm/ADT/SmallBitVector.h index a3469a1c62..d43c7afb10 100644 --- a/include/llvm/ADT/SmallBitVector.h +++ b/include/llvm/ADT/SmallBitVector.h @@ -15,6 +15,7 @@ #define LLVM_ADT_SMALLBITVECTOR_H #include "llvm/ADT/BitVector.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" #include <cassert> @@ -152,6 +153,12 @@ public: switchToLarge(new BitVector(*RHS.getPointer())); } +#if LLVM_USE_RVALUE_REFERENCES + SmallBitVector(SmallBitVector &&RHS) : X(RHS.X) { + RHS.X = 1; + } +#endif + ~SmallBitVector() { if (!isSmall()) delete getPointer(); @@ -422,6 +429,16 @@ public: return *this; } +#if LLVM_USE_RVALUE_REFERENCES + const SmallBitVector &operator=(SmallBitVector &&RHS) { + if (this != &RHS) { + clear(); + swap(RHS); + } + return *this; + } +#endif + void swap(SmallBitVector &RHS) { std::swap(X, RHS.X); } |