diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-27 16:22:08 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-27 16:22:08 +0000 |
commit | e3f75f8797b9752bfe7923bff9a87a15a6fe3552 (patch) | |
tree | 695bc5f1fdc69e5b969b533c16c1c1d6ff255635 /include/llvm/ADT | |
parent | 542c063f9614a6d11cffb3b8f1802e62f3a46136 (diff) | |
download | external_llvm-e3f75f8797b9752bfe7923bff9a87a15a6fe3552.zip external_llvm-e3f75f8797b9752bfe7923bff9a87a15a6fe3552.tar.gz external_llvm-e3f75f8797b9752bfe7923bff9a87a15a6fe3552.tar.bz2 |
Move-enable IntrusiveRefCntPtr.
These tend to be copied around a lot, moving it instead saves a ton of memory
accesses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/IntrusiveRefCntPtr.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/include/llvm/ADT/IntrusiveRefCntPtr.h b/include/llvm/ADT/IntrusiveRefCntPtr.h index 3a1a3f4..947ccc4 100644 --- a/include/llvm/ADT/IntrusiveRefCntPtr.h +++ b/include/llvm/ADT/IntrusiveRefCntPtr.h @@ -21,9 +21,8 @@ #ifndef LLVM_ADT_INTRUSIVE_REF_CNT_PTR #define LLVM_ADT_INTRUSIVE_REF_CNT_PTR -#include <cassert> - #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" namespace llvm { @@ -123,6 +122,17 @@ namespace llvm { retain(); } +#if LLVM_USE_RVALUE_REFERENCES + IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) { + S.Obj = 0; + } + + template <class X> + IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.getPtr()) { + S.Obj = 0; + } +#endif + template <class X> IntrusiveRefCntPtr(const IntrusiveRefCntPtr<X>& S) : Obj(S.getPtr()) { @@ -134,6 +144,21 @@ namespace llvm { return *this; } +#if LLVM_USE_RVALUE_REFERENCES + IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) { + Obj = S.Obj; + S.Obj = 0; + return *this; + } + + template <class X> + IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr<X>&& S) { + Obj = S.getPtr(); + S.Obj = 0; + return *this; + } +#endif + template <class X> IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr<X>& S) { replace(S.getPtr()); |