mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-13 07:00:59 +00:00
Move-enable IntrusiveRefCntPtr.
These tend to be copied around a lot, moving it instead saves a ton of memory accesses. llvm-svn: 157535
This commit is contained in:
parent
ec2a9415cc
commit
c529ae7728
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user