diff options
| author | Michael Gottesman <mgottesman@apple.com> | 2015-01-19 02:09:54 +0000 |
|---|---|---|
| committer | Michael Gottesman <mgottesman@apple.com> | 2015-01-19 02:09:54 +0000 |
| commit | 4125886b38d042f95bf6abfa354b1fb4db2e9a54 (patch) | |
| tree | 7457ffb97733f43418e38b23276b5dacf7de0fb5 | |
| parent | 44b21749b9d60e7212bee632dd11e4df1b19dfd6 (diff) | |
| download | bcm5719-llvm-4125886b38d042f95bf6abfa354b1fb4db2e9a54.tar.gz bcm5719-llvm-4125886b38d042f95bf6abfa354b1fb4db2e9a54.zip | |
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.
llvm-svn: 226424
| -rw-r--r-- | llvm/include/llvm/ADT/TinyPtrVector.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/include/llvm/ADT/TinyPtrVector.h b/llvm/include/llvm/ADT/TinyPtrVector.h index 15137f5ebf8..58590f49dfe 100644 --- a/llvm/include/llvm/ADT/TinyPtrVector.h +++ b/llvm/include/llvm/ADT/TinyPtrVector.h @@ -25,11 +25,14 @@ namespace llvm { template <typename EltTy> class TinyPtrVector { public: - typedef llvm::SmallVector<EltTy, 4> VecTy; - typedef typename VecTy::value_type value_type; + using VecTy = llvm::SmallVector<EltTy, 4>; + using value_type = typename VecTy::value_type; + using PtrUnion = llvm::PointerUnion<EltTy, VecTy *>; - llvm::PointerUnion<EltTy, VecTy*> Val; +private: + PtrUnion Val; +public: TinyPtrVector() {} ~TinyPtrVector() { if (VecTy *V = Val.template dyn_cast<VecTy*>()) @@ -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<EltTy> 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<EltTy>() const { |

