-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
network: address socket interface pointer instead of name #12550
Conversation
Signed-off-by: Florin Coras <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Signed-off-by: Florin Coras <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks much better. Just some style nits.
@@ -47,6 +47,10 @@ std::string friendlyNameFromAbstractPath(absl::string_view path) { | |||
|
|||
} // namespace | |||
|
|||
static inline const SocketInterface* sockInterfaceOrDefault(const SocketInterface* sock_interface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: put this in unnamed namespace above, remove static
, doesn't have to be inline
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a C reflex of mine that I use instead of macros. Goal would be to convince the compiler to avoid extra function calls when not needed. But obviously, no strong opinion here ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++ inline
isn't guaranteed to be inlined, all are decided by compiler, it's more of working around one-definition rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood!
include/envoy/network/address.h
Outdated
*/ | ||
virtual const std::string& socketInterface() const PURE; | ||
virtual const Network::SocketInterface* socketInterface() const PURE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's return reference, it's no longer nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have to keep the const because of how we pass the SocketInterface pointer to the Address. Is that okay or were you thinking about something more complex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah of couse, const wherever possible :)
Signed-off-by: Florin Coras <[email protected]>
Signed-off-by: Florin Coras <[email protected]>
source/common/network/address_impl.h
Outdated
} | ||
|
||
std::string friendly_name_; | ||
std::string socket_interface_; | ||
const SocketInterface* socket_interface_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be const ref as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Signed-off-by: Florin Coras <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thank you for the review! |
Signed-off-by: Florin Coras [email protected]
Risk Level: Low
Testing: unit tests
Docs Changes: n/a
Release Notes: n/a