Skip to content

Conversation

muggenhor
Copy link

Taking this parameter by const reference forces us to copy it (because
we know we're going to store it). Taking it by r-value reference would
suggest that we might take ownership over it and would also force the
user to make a copy if they wish to retain the original value.

Taking this parameter by value however clearly gives us ownership of its
content without forcing a copy if it's implicit conversion from
const char* or explicitly handed over to us by the user via std::move.

Also note that without this the std::move call already present in parse
is effectively a NOP. (I.e. it calls the const r-value ref constructor of
std::string, which doesn't exist, so falls back to const l-value ref.).

Taking this parameter by const reference forces us to copy it (because
we know we're going to store it). Taking it by r-value reference would
suggest that we _might_ take ownership over it and would also force the
user to make a copy if they wish to retain the original value.

Taking this parameter by value however clearly gives us ownership of its
content without forcing a copy if it's implicit conversion from
`const char*` or explicitly handed over to us by the user via std::move.
@ToruNiina
Copy link
Owner

This looks nice. After checking CI results, I will merge it.

@muggenhor muggenhor closed this Jun 3, 2022
@muggenhor muggenhor deleted the fix/avoid-fname-copy branch June 3, 2022 13:25
@ToruNiina
Copy link
Owner

?

@ToruNiina
Copy link
Owner

Your change has not been merged yet. And this change is worth merging. Also, it seems that all the CI tests pass. Could you restore the branch and reopen this Pull Req? If you don't want to be listed at contributors for some reason, then I will add this manually. Could you tell me what should I do?

@muggenhor muggenhor restored the fix/avoid-fname-copy branch June 4, 2022 10:05
@muggenhor
Copy link
Author

muggenhor commented Jun 4, 2022

I have no idea what happened. Maybe when I was cleaning up branches in some other unrelated repos I accidentally deleted this one as well?

Anyway, I restored the branch and PR. Apologies for the inconvenience and weirdness.

@muggenhor muggenhor reopened this Jun 4, 2022
@ToruNiina ToruNiina merged commit 6d9e533 into ToruNiina:master Jun 4, 2022
@ToruNiina
Copy link
Owner

Thank you!

@muggenhor muggenhor deleted the fix/avoid-fname-copy branch June 7, 2022 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants