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:
parent
15fc71cfcf
commit
f06461d208
|
@ -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 {};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue