Common/Network: Make StringToMacAddress use a string_view

This function only ever reads the contents of the string in a non-owning
manner, so we can change the parameter over to being a string view.
This commit is contained in:
Lioncash 2019-12-06 09:43:42 -05:00
parent 15fc71cfcf
commit f06461d208
2 changed files with 3 additions and 2 deletions

View File

@ -43,7 +43,7 @@ std::string MacAddressToString(const MACAddress& mac)
mac[4], mac[5]);
}
std::optional<MACAddress> StringToMacAddress(const std::string& mac_string)
std::optional<MACAddress> StringToMacAddress(std::string_view mac_string)
{
if (mac_string.empty())
return {};

View File

@ -7,6 +7,7 @@
#include <array>
#include <optional>
#include <string>
#include <string_view>
#include "Common/CommonTypes.h"
@ -27,5 +28,5 @@ using MACAddress = std::array<u8, MAC_ADDRESS_SIZE>;
MACAddress GenerateMacAddress(MACConsumer type);
std::string MacAddressToString(const MACAddress& mac);
std::optional<MACAddress> StringToMacAddress(const std::string& mac_string);
std::optional<MACAddress> StringToMacAddress(std::string_view mac_string);
} // namespace Common