From: Michael Gottesman Date: Mon, 19 Jan 2015 02:09:54 +0000 (+0000) Subject: Hide the state of TinyPtrVector and remove the single element constructor. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b0b28ca4850592dbca75244ddc61499aca240e89;p=oota-llvm.git Hide the state of TinyPtrVector and remove the single element constructor. There is no reason for this state to be exposed as public. The single element constructor was superfulous in light of the single element ArrayRef constructor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226424 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h index 15137f5ebf8..58590f49dfe 100644 --- a/include/llvm/ADT/TinyPtrVector.h +++ b/include/llvm/ADT/TinyPtrVector.h @@ -25,11 +25,14 @@ namespace llvm { template class TinyPtrVector { public: - typedef llvm::SmallVector VecTy; - typedef typename VecTy::value_type value_type; + using VecTy = llvm::SmallVector; + using value_type = typename VecTy::value_type; + using PtrUnion = llvm::PointerUnion; - llvm::PointerUnion Val; +private: + PtrUnion Val; +public: TinyPtrVector() {} ~TinyPtrVector() { if (VecTy *V = Val.template dyn_cast()) @@ -96,12 +99,13 @@ public: return *this; } - /// Constructor from a single element. - explicit TinyPtrVector(EltTy Elt) : Val(Elt) {} - /// Constructor from an ArrayRef. + /// + /// This also is a constructor for individual array elements due to the single + /// element constructor for ArrayRef. explicit TinyPtrVector(ArrayRef Elts) - : Val(new VecTy(Elts.begin(), Elts.end())) {} + : Val(Elts.size() == 1 ? PtrUnion(Elts[0]) + : PtrUnion(new VecTy(Elts.begin(), Elts.end()))) {} // implicit conversion operator to ArrayRef. operator ArrayRef() const {