aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-03-06 20:40:02 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-03-06 20:40:02 +0000
commit2945a32ffd0bf079de1b23db12bc8a0de596a167 (patch)
treea54746b6880314aa1eca572f0449adb4f491399f /include/llvm/ADT
parent54427e52197ecd8c748736d7bbb431f2bf65c90e (diff)
downloadexternal_llvm-2945a32ffd0bf079de1b23db12bc8a0de596a167.zip
external_llvm-2945a32ffd0bf079de1b23db12bc8a0de596a167.tar.gz
external_llvm-2945a32ffd0bf079de1b23db12bc8a0de596a167.tar.bz2
SmallPtrSet: Provide a more efficient implementation of swap than the default triple-copy std::swap.
This currently assumes that both sets have the same SmallSize to keep the implementation simple, a limitation that can be lifted if someone cares. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r--include/llvm/ADT/SmallPtrSet.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h
index 9992858..70693d5 100644
--- a/include/llvm/ADT/SmallPtrSet.h
+++ b/include/llvm/ADT/SmallPtrSet.h
@@ -137,6 +137,10 @@ private:
void operator=(const SmallPtrSetImpl &RHS); // DO NOT IMPLEMENT.
protected:
+ /// swap - Swaps the elements of two sets.
+ /// Note: This method assumes that both sets have the same small size.
+ void swap(SmallPtrSetImpl &RHS);
+
void CopyFrom(const SmallPtrSetImpl &RHS);
};
@@ -287,8 +291,20 @@ public:
return *this;
}
+ /// swap - Swaps the elements of two sets.
+ void swap(SmallPtrSet<PtrType, SmallSize> &RHS) {
+ SmallPtrSetImpl::swap(RHS);
+ }
};
}
+namespace std {
+ /// Implement std::swap in terms of SmallPtrSet swap.
+ template<class T, unsigned N>
+ inline void swap(llvm::SmallPtrSet<T, N> &LHS, llvm::SmallPtrSet<T, N> &RHS) {
+ LHS.swap(RHS);
+ }
+}
+
#endif