]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/msg_type: use fmt::format to print entity_addr
authorKefu Chai <tchaikov@gmail.com>
Sat, 11 Jun 2022 07:46:45 +0000 (15:46 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 11 Jun 2022 07:46:45 +0000 (15:46 +0800)
for better readability

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/msg/msg_types.cc

index 1a78cb32680986285d882b15d3d92742eab622e7..d4114b06e5975cf20a45acf8d9e78f43c69a710a 100644 (file)
@@ -8,6 +8,8 @@
 #include <string.h>
 #include <netdb.h>
 
+#include <fmt/format.h>
+
 #include "common/Formatter.h"
 
 bool entity_name_t::parse(std::string_view s)
@@ -413,13 +415,9 @@ std::string entity_addr_t::ip_only_to_str() const
 
 std::string entity_addr_t::ip_n_port_to_str() const
 {
-  std::string addr;
-  addr += ip_only_to_str();
   if (is_ipv6()) {
-    addr = '[' + addr + ']';
+    return fmt::format("[{}]:{}", ip_only_to_str(), get_port());
+  } else {
+    return fmt::format("{}:{}", ip_only_to_str(), get_port());
   }
-  addr += ':';
-  addr += std::to_string(get_port());
-  return addr;
 }
-