[llvm-commits] [llvm] r157535 - /llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
Benjamin Kramer
benny.kra at googlemail.com
Sun May 27 09:22:08 PDT 2012
Author: d0k
Date: Sun May 27 11:22:08 2012
New Revision: 157535
URL: http://llvm.org/viewvc/llvm-project?rev=157535&view=rev
Log:
Move-enable IntrusiveRefCntPtr.
These tend to be copied around a lot, moving it instead saves a ton of memory
accesses.
Modified:
llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=157535&r1=157534&r2=157535&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original)
+++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Sun May 27 11:22:08 2012
@@ -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 @@
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 @@
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());
More information about the llvm-commits
mailing list