Merge branch 'master' into Shellcode

dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
Grzegorz Rychlik 2020-01-07 18:02:23 +01:00
commit 474662bc8e
2 changed files with 22 additions and 5 deletions

View File

@ -329,11 +329,7 @@ namespace MWR
if (lhs.size() != rhs.size())
return false;
for (size_t i = 0; i < lhs.size(); ++i)
if (lhs[i] != rhs[i])
return false;
return true;
return !memcmp(lhs.data(), rhs.data(), lhs.size());
}
/// Checks if the contents of lhs and rhs are equal.

View File

@ -135,6 +135,8 @@ namespace MWR
using Super::find_last_not_of;
using Super::npos;
using Super::value_type;
friend inline bool operator==(ByteView const& lhs, ByteView const& rhs);
friend inline bool operator!=(ByteView const& lhs, ByteView const& rhs);
/// Read bytes and move ByteView to position after parsed data.
/// @param byteCount. How many bytes should be read.
@ -231,6 +233,25 @@ namespace MWR
return { reinterpret_cast<const uint8_t*>(data), size * sizeof(wchar_t) };
}
}
/// Checks if the contents of lhs and rhs are equal.
/// @param lhs. Left hand side of operator.
/// @param rhs. Right hand side of operator.
inline bool operator==(MWR::ByteView const& lhs, MWR::ByteView const& rhs)
{
if (lhs.size() != rhs.size())
return false;
return !memcmp(lhs.data(), rhs.data(), lhs.size());
}
/// Checks if the contents of lhs and rhs are equal.
/// @param lhs. Left hand side of operator.
/// @param rhs. Right hand side of operator.
inline bool operator!=(MWR::ByteView const& lhs, MWR::ByteView const& rhs)
{
return !(lhs == rhs);
}
}
namespace std