use fmt::to_string() for seastar::net::inet_address

This change removes inet_addr_type_impl::to_sstring()
and replaces its usages with fmt::to_string().
The removed helper performed an uneeded copying via
std::ostringstream::str().

Signed-off-by: Patryk Wrobel <patryk.wrobel@scylladb.com>
This commit is contained in:
Patryk Wrobel
2024-02-05 16:56:40 +01:00
parent 8c0d30cd88
commit cc186c1798
3 changed files with 2 additions and 9 deletions

View File

@@ -131,7 +131,6 @@ struct varint_type_impl final : public concrete_type<utils::multiprecision_int>
struct inet_addr_type_impl final : public concrete_type<seastar::net::inet_address> {
inet_addr_type_impl();
static sstring to_sstring(const seastar::net::inet_address& addr);
static seastar::net::inet_address from_sstring(sstring_view s);
};

View File

@@ -1030,7 +1030,7 @@ struct to_lua_visitor {
void operator()(const inet_addr_type_impl& t, const emptyable<seastar::net::inet_address>* v) {
// returns a string
sstring s = inet_addr_type_impl::to_sstring(v->get());
sstring s = fmt::to_string(v->get());
push_sstring(l, s);
}

View File

@@ -115,12 +115,6 @@ sstring boolean_to_string(const bool b) {
return b ? "true" : "false";
}
sstring inet_addr_type_impl::to_sstring(const seastar::net::inet_address& addr) {
std::ostringstream out;
out << addr;
return out.str();
}
static const char* byte_type_name = "org.apache.cassandra.db.marshal.ByteType";
static const char* short_type_name = "org.apache.cassandra.db.marshal.ShortType";
static const char* int32_type_name = "org.apache.cassandra.db.marshal.Int32Type";
@@ -2882,7 +2876,7 @@ struct to_string_impl_visitor {
}
sstring operator()(const empty_type_impl&, const void*) { return sstring(); }
sstring operator()(const inet_addr_type_impl& a, const inet_addr_type_impl::native_type* v) {
return format_if_not_empty(a, v, inet_addr_type_impl::to_sstring);
return format_if_not_empty(a, v, [] (const seastar::net::inet_address& addr) { return fmt::to_string(addr); });
}
sstring operator()(const list_type_impl& l, const list_type_impl::native_type* v) {
return format_if_not_empty(