diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-03-12 00:37:23 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-03-12 22:32:38 +0100 |
commit | cbade33906dc0d090d5dba6231fb48e359afff95 (patch) | |
tree | 391399754e43332fa7bde336255dd17d83683228 /asl/containers | |
parent | c8b73031d8a9f7770410c9d0e6da5b230e501e85 (diff) |
Some more shit
Diffstat (limited to 'asl/containers')
-rw-r--r-- | asl/containers/buffer.hpp | 28 | ||||
-rw-r--r-- | asl/containers/hash_set.hpp | 4 | ||||
-rw-r--r-- | asl/containers/intrusive_list.hpp | 2 |
3 files changed, 17 insertions, 17 deletions
diff --git a/asl/containers/buffer.hpp b/asl/containers/buffer.hpp index c7fc01f..0cad78f 100644 --- a/asl/containers/buffer.hpp +++ b/asl/containers/buffer.hpp @@ -46,7 +46,7 @@ private: static_assert(align_of<T*> == align_of<isize_t>); static_assert(align_of<T*> == align_of<size_t>); - constexpr size_t load_size_encoded() const + [[nodiscard]] constexpr size_t load_size_encoded() const { size_t s{}; asl::memcpy(&s, &m_size_encoded_, sizeof(size_t)); @@ -84,21 +84,21 @@ private: } } - constexpr bool is_on_heap() const + [[nodiscard]] constexpr bool is_on_heap() const { return is_on_heap(load_size_encoded()); } constexpr T* push_uninit() { - isize_t sz = size(); + const isize_t sz = size(); resize_uninit_inner(sz + 1); return data() + sz; } constexpr void resize_uninit_inner(isize_t new_size) { - isize_t old_size = size(); + const isize_t old_size = size(); if (!trivially_destructible<T> && new_size < old_size) { destroy_n(data() + new_size, old_size - new_size); @@ -110,7 +110,7 @@ private: constexpr void set_size_inline(isize_t new_size) { ASL_ASSERT(new_size >= 0 && new_size <= kInlineCapacity); - size_t size_encoded = (load_size_encoded() & size_t{0x00ff'ffff'ffff'ffff}) | (bit_cast<size_t>(new_size) << 56U); + const size_t size_encoded = (load_size_encoded() & size_t{0x00ff'ffff'ffff'ffff}) | (bit_cast<size_t>(new_size) << 56U); store_size_encoded(size_encoded); } @@ -144,8 +144,8 @@ private: } else if (!assign || m_allocator == other.m_allocator) { - isize_t other_n = other.size(); - isize_t this_n = size(); + const isize_t other_n = other.size(); + const isize_t this_n = size(); resize_uninit_inner(other_n); if (other_n <= this_n) { @@ -160,7 +160,7 @@ private: else { destroy(); - isize_t n = other.size(); + const isize_t n = other.size(); ASL_ASSERT(n <= kInlineCapacity); relocate_uninit_n(data(), other.data(), n); set_size_inline(n); @@ -176,8 +176,8 @@ private: void copy_range(span<const T> to_copy) { - isize_t this_size = size(); - isize_t new_size = to_copy.size(); + const isize_t this_size = size(); + const isize_t new_size = to_copy.size(); resize_uninit_inner(to_copy.size()); ASL_ASSERT(capacity() >= new_size); @@ -268,12 +268,12 @@ public: destroy(); } - constexpr isize_t size() const + [[nodiscard]] constexpr isize_t size() const { return decode_size(load_size_encoded()); } - constexpr isize_t capacity() const + [[nodiscard]] constexpr isize_t capacity() const { if constexpr (kInlineCapacity == 0) { @@ -287,7 +287,7 @@ public: void clear() { - isize_t current_size = size(); + const isize_t current_size = size(); if (current_size == 0) { return; } destroy_n(data(), current_size); @@ -357,7 +357,7 @@ public: constexpr void resize_zero(isize_t new_size) requires trivially_default_constructible<T> && trivially_destructible<T> { - isize_t old_size = size(); + const isize_t old_size = size(); resize_uninit(new_size); if (new_size > old_size) diff --git a/asl/containers/hash_set.hpp b/asl/containers/hash_set.hpp index 02a8036..5422d5e 100644 --- a/asl/containers/hash_set.hpp +++ b/asl/containers/hash_set.hpp @@ -72,7 +72,7 @@ protected: ASL_NO_UNIQUE_ADDRESS Allocator m_allocator; - constexpr isize_t max_size() const + [[nodiscard]] constexpr isize_t max_size() const { // Max load factor is 75% return (m_capacity >> 1) + (m_capacity >> 2); // NOLINT(*-signed-bitwise) @@ -384,7 +384,7 @@ public: } } - constexpr isize_t size() const { return m_size; } + [[nodiscard]] constexpr isize_t size() const { return m_size; } template<typename... Args> void insert(Args&&... args) diff --git a/asl/containers/intrusive_list.hpp b/asl/containers/intrusive_list.hpp index af11424..8cafdff 100644 --- a/asl/containers/intrusive_list.hpp +++ b/asl/containers/intrusive_list.hpp @@ -47,7 +47,7 @@ public: ASL_DEFAULT_MOVE(IntrusiveList); ~IntrusiveList() = default; - constexpr bool is_empty() const { return m_head == nullptr; } + [[nodiscard]] constexpr bool is_empty() const { return m_head == nullptr; } void push_front(T* node) { |