diff options
Diffstat (limited to 'src/support/small_vector.h')
-rw-r--r-- | src/support/small_vector.h | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/support/small_vector.h b/src/support/small_vector.h index e746700bf..dd6afb526 100644 --- a/src/support/small_vector.h +++ b/src/support/small_vector.h @@ -29,8 +29,7 @@ namespace wasm { -template<typename T, size_t N> -class SmallVector { +template<typename T, size_t N> class SmallVector { // fixed-space storage size_t usedFixed = 0; std::array<T, N> fixed; @@ -65,10 +64,9 @@ public: } } - template <typename... ArgTypes> - void emplace_back(ArgTypes &&... Args) { + template<typename... ArgTypes> void emplace_back(ArgTypes&&... Args) { if (usedFixed < N) { - new(&fixed[usedFixed++]) T(std::forward<ArgTypes>(Args)...); + new (&fixed[usedFixed++]) T(std::forward<ArgTypes>(Args)...); } else { flexible.emplace_back(std::forward<ArgTypes>(Args)...); } @@ -101,13 +99,9 @@ public: } } - size_t size() const { - return usedFixed + flexible.size(); - } + size_t size() const { return usedFixed + flexible.size(); } - bool empty() const { - return size() == 0; - } + bool empty() const { return size() == 0; } void clear() { usedFixed = 0; @@ -115,9 +109,11 @@ public: } bool operator==(const SmallVector<T, N>& other) const { - if (usedFixed != other.usedFixed) return false; + if (usedFixed != other.usedFixed) + return false; for (size_t i = 0; i < usedFixed; i++) { - if (fixed[i] != other.fixed[i]) return false; + if (fixed[i] != other.fixed[i]) + return false; } return flexible == other.flexible; } @@ -136,15 +132,14 @@ public: const SmallVector<T, N>* parent; size_t index; - Iterator(const SmallVector<T, N>* parent, size_t index) : parent(parent), index(index) {} + Iterator(const SmallVector<T, N>* parent, size_t index) + : parent(parent), index(index) {} bool operator!=(const Iterator& other) const { return index != other.index || parent != other.parent; } - void operator++() { - index++; - } + void operator++() { index++; } Iterator& operator+=(difference_type off) { index += off; @@ -155,9 +150,7 @@ public: return Iterator(*this) += off; } - const value_type operator*() const { - return (*parent)[index]; - } + const value_type operator*() const { return (*parent)[index]; } }; Iterator begin() const { |