mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
AK: Annotate more AK::Span methods as nodiscard
This commit is contained in:
parent
60efe18a31
commit
59ba316ac6
Notes:
sideshowbarker
2024-07-18 11:09:12 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/59ba316ac6e Pull-request: https://github.com/SerenityOS/serenity/pull/8373
38
AK/Span.h
38
AK/Span.h
@ -99,11 +99,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
ALWAYS_INLINE constexpr const T* data() const { return this->m_values; }
|
||||
ALWAYS_INLINE constexpr T* data() { return this->m_values; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr const T* data() const { return this->m_values; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr T* data() { return this->m_values; }
|
||||
|
||||
ALWAYS_INLINE constexpr const T* offset_pointer(size_t offset) const { return this->m_values + offset; }
|
||||
ALWAYS_INLINE constexpr T* offset_pointer(size_t offset) { return this->m_values + offset; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr const T* offset_pointer(size_t offset) const { return this->m_values + offset; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr T* offset_pointer(size_t offset) { return this->m_values + offset; }
|
||||
|
||||
using ConstIterator = SimpleIterator<const Span, const T>;
|
||||
using Iterator = SimpleIterator<Span, T>;
|
||||
@ -114,9 +114,9 @@ public:
|
||||
constexpr ConstIterator end() const { return ConstIterator::end(*this); }
|
||||
constexpr Iterator end() { return Iterator::end(*this); }
|
||||
|
||||
ALWAYS_INLINE constexpr size_t size() const { return this->m_size; }
|
||||
ALWAYS_INLINE constexpr bool is_null() const { return this->m_values == nullptr; }
|
||||
ALWAYS_INLINE constexpr bool is_empty() const { return this->m_size == 0; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr size_t size() const { return this->m_size; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_null() const { return this->m_values == nullptr; }
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr bool is_empty() const { return this->m_size == 0; }
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr Span slice(size_t start, size_t length) const
|
||||
{
|
||||
@ -139,7 +139,7 @@ public:
|
||||
return { this->m_values, min(size(), length) };
|
||||
}
|
||||
|
||||
ALWAYS_INLINE constexpr T* offset(size_t start) const
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr T* offset(size_t start) const
|
||||
{
|
||||
VERIFY(start < this->m_size);
|
||||
return this->m_values + start;
|
||||
@ -172,7 +172,7 @@ public:
|
||||
return size();
|
||||
}
|
||||
|
||||
bool constexpr contains_slow(const T& value) const
|
||||
[[nodiscard]] bool constexpr contains_slow(const T& value) const
|
||||
{
|
||||
for (size_t i = 0; i < size(); ++i) {
|
||||
if (at(i) == value)
|
||||
@ -181,7 +181,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool constexpr starts_with(Span<const T> other) const
|
||||
[[nodiscard]] bool constexpr starts_with(Span<const T> other) const
|
||||
{
|
||||
if (size() < other.size())
|
||||
return false;
|
||||
@ -189,22 +189,24 @@ public:
|
||||
return TypedTransfer<T>::compare(data(), other.data(), other.size());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE constexpr const T& at(size_t index) const
|
||||
{
|
||||
VERIFY(index < this->m_size);
|
||||
return this->m_values[index];
|
||||
}
|
||||
ALWAYS_INLINE constexpr T& at(size_t index)
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr const T& at(size_t index) const
|
||||
{
|
||||
VERIFY(index < this->m_size);
|
||||
return this->m_values[index];
|
||||
}
|
||||
|
||||
ALWAYS_INLINE constexpr const T& operator[](size_t index) const
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr T& at(size_t index)
|
||||
{
|
||||
VERIFY(index < this->m_size);
|
||||
return this->m_values[index];
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr const T& operator[](size_t index) const
|
||||
{
|
||||
return at(index);
|
||||
}
|
||||
ALWAYS_INLINE constexpr T& operator[](size_t index)
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr T& operator[](size_t index)
|
||||
{
|
||||
return at(index);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user