Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common/Network: Make StringToMacAddress use a string_view #8514

Merged
merged 3 commits into from Dec 6, 2019

Conversation

@lioncash
Copy link
Member

lioncash commented Dec 6, 2019

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.

lioncash added 2 commits Dec 6, 2019
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.
Removes unused header dependencies.
@@ -43,7 +41,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 {};

This comment has been minimized.

Copy link
@CookiePLMonster

CookiePLMonster Dec 6, 2019

Contributor

You yourself recommended std::nullopt a while back, would be a good fit there. Since this PR only touches a single function, I see no reason not to go for it together with string_view change.

Prevents unnecessary zeroing out of std::optional's internal buffer in
some implementations.
@JosJuice JosJuice merged commit 5a5c46a into dolphin-emu:master Dec 6, 2019
10 checks passed
10 checks passed
default Very basic checks passed, handed off to Buildbot.
Details
lint Build succeeded on builder lint
Details
pr-android Build succeeded on builder pr-android
Details
pr-deb-dbg-x64 Build succeeded on builder pr-deb-dbg-x64
Details
pr-deb-x64 Build succeeded on builder pr-deb-x64
Details
pr-freebsd-x64 Build succeeded on builder pr-freebsd-x64
Details
pr-osx-x64 Build succeeded on builder pr-osx-x64
Details
pr-ubu-x64 Build succeeded on builder pr-ubu-x64
Details
pr-win-dbg-x64 Build succeeded on builder pr-win-dbg-x64
Details
pr-win-x64 Build succeeded on builder pr-win-x64
Details
@lioncash lioncash deleted the lioncash:sview branch Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.