instead of creating an empty string and then mutating it, just
assign the return value of `eaddr.ip_n_port_to_str()` to it.
as C++17 enforces copy ellision in this case, we can avoid
two unnecessary calls here:
- creating a temporary object and destroying it.
- memcpy the temporary object.
also, after this change, the code is simpler.
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
continue;
}
- std::string addr;
- addr += eaddr.ip_n_port_to_str();
+ std::string addr = eaddr.ip_n_port_to_str();
/* If this will overrun cci_mons, stop here */
if (monaddrs.length() + 1 + addr.length() + 1 > sizeof(cci->cci_mons))
break;