Common/Network: Use std::nullopt in StringToMacAddress

Prevents unnecessary zeroing out of std::optional's internal buffer in
some implementations.
This commit is contained in:
Lioncash 2019-12-06 09:59:09 -05:00
parent cbfacc41ba
commit 81edcca8db

View File

@ -44,7 +44,7 @@ std::string MacAddressToString(const MACAddress& mac)
std::optional<MACAddress> StringToMacAddress(std::string_view mac_string)
{
if (mac_string.empty())
return {};
return std::nullopt;
int x = 0;
MACAddress mac{};
@ -68,7 +68,7 @@ std::optional<MACAddress> StringToMacAddress(std::string_view mac_string)
// nibble is a character in the MAC address, making 12 characters
// in total.
if (x / 2 != MAC_ADDRESS_SIZE)
return {};
return std::nullopt;
return std::make_optional(mac);
}