]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/ProtocolV2: pass `desc` as `std::string_view` to write() 60106/head
authorMax Kellermann <max.kellermann@ionos.com>
Thu, 3 Oct 2024 15:21:23 +0000 (17:21 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Mon, 7 Oct 2024 20:43:30 +0000 (22:43 +0200)
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 <max.kellermann@ionos.com>
src/msg/async/ProtocolV2.cc
src/msg/async/ProtocolV2.h

index 6d44d6c783f44adadae56527c4fc0d2a67ba4977..c4cfa76d16f15173bd50730769cf589ce8ae99b7 100644 (file)
@@ -796,7 +796,7 @@ CtPtr ProtocolV2::read(CONTINUATION_RXBPTR_TYPE<ProtocolV2> &next,
 }
 
 template <class F>
-CtPtr ProtocolV2::write(const std::string &desc,
+CtPtr ProtocolV2::write(std::string_view desc,
                         CONTINUATION_TYPE<ProtocolV2> &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<ProtocolV2> &next,
                         ceph::bufferlist &buffer) {
   if (unlikely(pre_auth.enabled)) {
index 6441866fea4c33a6885df660b75dd6608b9384a2..918003a21ced7860e3be1d9287c8600e76da5e53 100644 (file)
@@ -130,10 +130,10 @@ private:
   Ct<ProtocolV2> *read(CONTINUATION_RXBPTR_TYPE<ProtocolV2> &next,
                        rx_buffer_t&& buffer);
   template <class F>
-  Ct<ProtocolV2> *write(const std::string &desc,
+  Ct<ProtocolV2> *write(std::string_view desc,
                         CONTINUATION_TYPE<ProtocolV2> &next,
                        F &frame);
-  Ct<ProtocolV2> *write(const std::string &desc,
+  Ct<ProtocolV2> *write(std::string_view desc,
                         CONTINUATION_TYPE<ProtocolV2> &next,
                         ceph::bufferlist &buffer);