cleanup: expose address string_view accessor#7732
Merged
mattklein123 merged 2 commits intoenvoyproxy:masterfrom Jul 26, 2019
Merged
cleanup: expose address string_view accessor#7732mattklein123 merged 2 commits intoenvoyproxy:masterfrom
mattklein123 merged 2 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
lizan
suggested changes
Jul 26, 2019
Member
lizan
left a comment
There was a problem hiding this comment.
we don't copy already by returning const std::string&, and it converts to absl::string_view implicitly without copy anyway, what does this solve?
Contributor
Author
|
The problem it's trying to solve is to make it explicit :) I'd like the final string view to point to the memory allocated inside the IP address instance. If a string is copied (due to a compiler optimization off, someone changing the interface from reference to value), then the final string view points to a copy, which has a distinct life time than the IP address (it might be block-bound). |
mattklein123
approved these changes
Jul 26, 2019
Member
mattklein123
left a comment
There was a problem hiding this comment.
Optimally you would go back and remove the asString() function, though that would be a huge change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Kuat Yessenov kuat@google.com
Description: expose address instance string_view accessor. It already owns the string, so we can avoid the copy.
Risk Level: low
Testing: unit tests
Docs Changes:
Release Notes: