Eliminate unnecessary cast in endpoint::from_string
This commit is contained in:
parent
21db937ba7
commit
b6e38cd5ec
1 changed files with 4 additions and 5 deletions
|
|
@ -55,12 +55,11 @@ namespace fc { namespace ip {
|
||||||
uint16_t endpoint::port()const { return _port; }
|
uint16_t endpoint::port()const { return _port; }
|
||||||
const address& endpoint::get_address()const { return _ip; }
|
const address& endpoint::get_address()const { return _ip; }
|
||||||
|
|
||||||
endpoint endpoint::from_string( const string& s ) {
|
endpoint endpoint::from_string( const string& endpoint_string ) {
|
||||||
endpoint ep;
|
endpoint ep;
|
||||||
const std::string& st = reinterpret_cast<const std::string&>(s);
|
auto pos = endpoint_string.find(':');
|
||||||
auto pos = st.find(':');
|
ep._ip = boost::asio::ip::address_v4::from_string(endpoint_string.substr( 0, pos ) ).to_ulong();
|
||||||
ep._ip = boost::asio::ip::address_v4::from_string(st.substr( 0, pos ) ).to_ulong();
|
ep._port = boost::lexical_cast<uint16_t>( endpoint_string.substr( pos+1, endpoint_string.size() ) );
|
||||||
ep._port = boost::lexical_cast<uint16_t>( st.substr( pos+1, s.size() ) );
|
|
||||||
return ep;
|
return ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue