diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-06-28 11:04:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-28 11:04:10 +0200 |
commit | 5ab59ee7df1d344dccc9deef375faa46deb63b8d (patch) | |
tree | 442c77210597a549e43d425f2a4ec55e703cb2dd /core | |
parent | 16d9918b514d4d2d7fb846de8f2b1107aefab0b9 (diff) | |
parent | a82352c7e31655f070246fbac7410f965f2370a6 (diff) |
Merge pull request #55954 from RandomShaper/vulkan_rd_goodies
Diffstat (limited to 'core')
-rw-r--r-- | core/templates/local_vector.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/templates/local_vector.h b/core/templates/local_vector.h index f4e0748c27..8d687effcf 100644 --- a/core/templates/local_vector.h +++ b/core/templates/local_vector.h @@ -38,7 +38,9 @@ #include <initializer_list> -template <class T, class U = uint32_t, bool force_trivial = false> +// If tight, it grows strictly as much as needed. +// Otherwise, it grows exponentially (the default and what you want in most cases). +template <class T, class U = uint32_t, bool force_trivial = false, bool tight = false> class LocalVector { private: U count = 0; @@ -121,7 +123,7 @@ public: _FORCE_INLINE_ bool is_empty() const { return count == 0; } _FORCE_INLINE_ U get_capacity() const { return capacity; } _FORCE_INLINE_ void reserve(U p_size) { - p_size = nearest_power_of_2_templated(p_size); + p_size = tight ? p_size : nearest_power_of_2_templated(p_size); if (p_size > capacity) { capacity = p_size; data = (T *)memrealloc(data, capacity * sizeof(T)); @@ -262,4 +264,7 @@ public: } }; +template <class T, class U = uint32_t, bool force_trivial = false> +using TightLocalVector = LocalVector<T, U, force_trivial, true>; + #endif // LOCAL_VECTOR_H |