mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 09:49:21 +00:00
AK: Simplify Array::back()
by checking for Size > 0
We do not want `Array::max()` to be used here at all - we know the size at compile-time, after all.
This commit is contained in:
parent
65df30d00c
commit
bc36e39d07
Notes:
sideshowbarker
2024-07-17 22:58:04 +09:00
Author: https://github.com/gmta
Commit: bc36e39d07
Pull-request: https://github.com/SerenityOS/serenity/pull/11108
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/sunverwerth ✅
1 changed files with 2 additions and 2 deletions
|
@ -35,8 +35,8 @@ struct Array {
|
||||||
[[nodiscard]] constexpr T const& front() const { return at(0); }
|
[[nodiscard]] constexpr T const& front() const { return at(0); }
|
||||||
[[nodiscard]] constexpr T& front() { return at(0); }
|
[[nodiscard]] constexpr T& front() { return at(0); }
|
||||||
|
|
||||||
[[nodiscard]] constexpr T const& back() const { return at(max(1, size()) - 1); }
|
[[nodiscard]] constexpr T const& back() const requires(Size > 0) { return at(Size - 1); }
|
||||||
[[nodiscard]] constexpr T& back() { return at(max(1, size()) - 1); }
|
[[nodiscard]] constexpr T& back() requires(Size > 0) { return at(Size - 1); }
|
||||||
|
|
||||||
[[nodiscard]] constexpr bool is_empty() const { return size() == 0; }
|
[[nodiscard]] constexpr bool is_empty() const { return size() == 0; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue