mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 04:13:11 +00: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
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AllOf.h>
|
||||
#include <AK/Array.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -79,7 +80,7 @@ public:
|
|||
|
||||
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:
|
||||
|
|
Loading…
Reference in a new issue