From: Max Kellermann Date: Thu, 3 Oct 2024 15:21:23 +0000 (+0200) Subject: msg/async/ProtocolV2: pass `desc` as `std::string_view` to write() X-Git-Tag: v20.0.0~788^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=966920e063cc1fa276fbc09798779d71be51947d;p=ceph.git msg/async/ProtocolV2: pass `desc` as `std::string_view` to write() All callers really pass a C string literal, and declaring a `std::string` parameter will implicitly create two `std::string` instances: one on the caller's stack, and another one inside write() as parameter to the continuation lambda. This causes considerable and unnecessary overhead. Signed-off-by: Max Kellermann --- diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index 6d44d6c783f..c4cfa76d16f 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -796,7 +796,7 @@ CtPtr ProtocolV2::read(CONTINUATION_RXBPTR_TYPE &next, } template -CtPtr ProtocolV2::write(const std::string &desc, +CtPtr ProtocolV2::write(std::string_view desc, CONTINUATION_TYPE &next, F &frame) { ceph::bufferlist bl; @@ -812,7 +812,7 @@ CtPtr ProtocolV2::write(const std::string &desc, return write(desc, next, bl); } -CtPtr ProtocolV2::write(const std::string &desc, +CtPtr ProtocolV2::write(std::string_view desc, CONTINUATION_TYPE &next, ceph::bufferlist &buffer) { if (unlikely(pre_auth.enabled)) { diff --git a/src/msg/async/ProtocolV2.h b/src/msg/async/ProtocolV2.h index 6441866fea4..918003a21ce 100644 --- a/src/msg/async/ProtocolV2.h +++ b/src/msg/async/ProtocolV2.h @@ -130,10 +130,10 @@ private: Ct *read(CONTINUATION_RXBPTR_TYPE &next, rx_buffer_t&& buffer); template - Ct *write(const std::string &desc, + Ct *write(std::string_view desc, CONTINUATION_TYPE &next, F &frame); - Ct *write(const std::string &desc, + Ct *write(std::string_view desc, CONTINUATION_TYPE &next, ceph::bufferlist &buffer);