mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
MACAddress: Use all_of to implement is_zero
Problem: - `is_zero()` is implemented by checking each value in the array by hand. This is error-prone and less expressive than using an algorithm. Solution: - Implement `is_zero()` in terms of `all_of`.
This commit is contained in:
parent
6e7e16a7ed
commit
178190ab52
Notes:
sideshowbarker
2024-07-19 01:20:09 +09:00
Author: https://github.com/ldm5180
Commit: 178190ab52
Pull-request: https://github.com/SerenityOS/serenity/pull/4128
1 changed files with 2 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/AllOf.h>
|
||||||
#include <AK/Array.h>
|
#include <AK/Array.h>
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
@ -79,7 +80,7 @@ public:
|
||||||
|
|
||||||
constexpr bool is_zero() const
|
constexpr bool is_zero() const
|
||||||
{
|
{
|
||||||
return m_data[0] == 0 && m_data[1] == 0 && m_data[2] == 0 && m_data[3] == 0 && m_data[4] == 0 && m_data[5] == 0;
|
return AK::all_of(m_data.begin(), m_data.end(), [](const auto octet) { return octet == 0; });
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue