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
1 changed files with 2 additions and 2 deletions

View File

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