diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-07-13 17:21:42 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-07-13 17:21:42 +0000 |
commit | 4ba675006b5a8edfc48b6a9bd3dcf54a70cc08f2 (patch) | |
tree | 48b44512b5db8ced345df4a1a56b5065cf2a14d9 /include/clang/AST/UsuallyTinyPtrVector.h | |
parent | d7279c4c177bca357ef96ff1379fd9bc420bfe83 (diff) |
Diffstat (limited to 'include/clang/AST/UsuallyTinyPtrVector.h')
-rw-r--r-- | include/clang/AST/UsuallyTinyPtrVector.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/clang/AST/UsuallyTinyPtrVector.h b/include/clang/AST/UsuallyTinyPtrVector.h index 5ee40e05c956..534d4d4a367f 100644 --- a/include/clang/AST/UsuallyTinyPtrVector.h +++ b/include/clang/AST/UsuallyTinyPtrVector.h @@ -41,6 +41,7 @@ public: typedef const T **iterator; iterator begin() const; iterator end() const; + size_t size() const; void push_back(T *Method); void Destroy(); @@ -56,7 +57,6 @@ UsuallyTinyPtrVector<T>::begin() const { return &Vec->front(); } - template<typename T> typename UsuallyTinyPtrVector<T>::iterator UsuallyTinyPtrVector<T>::end() const { @@ -72,6 +72,15 @@ UsuallyTinyPtrVector<T>::end() const { } template<typename T> +size_t UsuallyTinyPtrVector<T>::size() const { + if ((Storage & 0x01) == 0) + return (Storage == 0) ? 0 : 1; + + vector_type *Vec = reinterpret_cast<vector_type *>(Storage & ~0x01); + return Vec->size(); +} + +template<typename T> void UsuallyTinyPtrVector<T>::push_back(T *Element) { if (Storage == 0) { // 0 -> 1 element. |