llvm.org GIT mirror llvm / e3f75f8
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 Benjamin Kramer 8 years ago
1 changed file(s) with 27 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2020 #ifndef LLVM_ADT_INTRUSIVE_REF_CNT_PTR
2121 #define LLVM_ADT_INTRUSIVE_REF_CNT_PTR
2222
23 #include
24
2523 #include "llvm/Support/Casting.h"
24 #include "llvm/Support/Compiler.h"
2625
2726 namespace llvm {
2827
122121 retain();
123122 }
124123
124 #if LLVM_USE_RVALUE_REFERENCES
125 IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) {
126 S.Obj = 0;
127 }
128
129 template
130 IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.getPtr()) {
131 S.Obj = 0;
132 }
133 #endif
134
125135 template
126136 IntrusiveRefCntPtr(const IntrusiveRefCntPtr& S)
127137 : Obj(S.getPtr()) {
132142 replace(S.getPtr());
133143 return *this;
134144 }
145
146 #if LLVM_USE_RVALUE_REFERENCES
147 IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) {
148 Obj = S.Obj;
149 S.Obj = 0;
150 return *this;
151 }
152
153 template
154 IntrusiveRefCntPtr& operator=(IntrusiveRefCntPtr&& S) {
155 Obj = S.getPtr();
156 S.Obj = 0;
157 return *this;
158 }
159 #endif
135160
136161 template
137162 IntrusiveRefCntPtr& operator=(const IntrusiveRefCntPtr& S) {