Bug 901: Optimize Mac48Address operators
This commit is contained in:
@@ -221,36 +221,6 @@ Mac48Address Mac48Address::GetMulticast(Ipv6Address addr)
|
||||
return etherAddr;
|
||||
}
|
||||
|
||||
bool operator == (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return memcmp (a.m_address, b.m_address, 6) == 0;
|
||||
}
|
||||
bool operator != (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return ! (a == b);
|
||||
}
|
||||
|
||||
bool operator < (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
uint8_t aP[6];
|
||||
uint8_t bP[6];
|
||||
a.CopyTo (aP);
|
||||
b.CopyTo (bP);
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (a.m_address[i] < b.m_address[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (a.m_address[i] > b.m_address[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Mac48Address & address)
|
||||
{
|
||||
uint8_t ad[6];
|
||||
|
||||
@@ -135,6 +135,7 @@ private:
|
||||
static uint8_t GetType (void);
|
||||
friend bool operator < (const Mac48Address &a, const Mac48Address &b);
|
||||
friend bool operator == (const Mac48Address &a, const Mac48Address &b);
|
||||
friend bool operator != (const Mac48Address &a, const Mac48Address &b);
|
||||
friend std::istream& operator>> (std::istream& is, Mac48Address & address);
|
||||
|
||||
uint8_t m_address[6];
|
||||
@@ -147,9 +148,19 @@ private:
|
||||
|
||||
ATTRIBUTE_HELPER_HEADER (Mac48Address);
|
||||
|
||||
bool operator == (const Mac48Address &a, const Mac48Address &b);
|
||||
bool operator != (const Mac48Address &a, const Mac48Address &b);
|
||||
bool operator < (const Mac48Address &a, const Mac48Address &b);
|
||||
inline bool operator == (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return memcmp (a.m_address, b.m_address, 6) == 0;
|
||||
}
|
||||
inline bool operator != (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return memcmp (a.m_address, b.m_address, 6) != 0;
|
||||
}
|
||||
inline bool operator < (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return memcmp (a.m_address, b.m_address, 6) < 0;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Mac48Address & address);
|
||||
std::istream& operator>> (std::istream& is, Mac48Address & address);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user