Change the constructor host_port(rpc_address addr) to a static function
host_port from_address(rpc_address addr). It's a good practice to keep
constructors light and fast, this function contains a reverse DNS lookup,
it may be slow.
Change bool from_string(const std::string &s) to a static function
host_port from_string(const std::string &host_port_str) in host_port.
It seems there isn't a scenario to modify an exist host_port object by
calling obj.from_string(s), so make it as static to clarify this.
This patch also adds SCOPED_LOG_SLOW_EXECUTION to log slow operations if it
exceed 100 milliseconds.
This patch mainly has cchanges:
Change the constructor
host_port(rpc_address addr)
to a static functionhost_port from_address(rpc_address addr)
. It's a good practice to keep constructors light and fast, this function contains a reverse DNS lookup, it may be slow.Change
bool from_string(const std::string &s)
to a static functionhost_port from_string(const std::string &host_port_str)
in host_port. It seems there isn't a scenario to modify an exist host_port object by calling obj.from_string(s), so make it as static to clarify this.This patch also adds SCOPED_LOG_SLOW_EXECUTION to log slow operations if it exceed 100 milliseconds.