summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@ionos.com>2024-10-03 17:21:23 +0200
committerMax Kellermann <max.kellermann@ionos.com>2024-10-07 22:43:30 +0200
commit966920e063cc1fa276fbc09798779d71be51947d (patch)
treed00f8d630ea3a7f4b64092dd02dbced2f92fdab5
parentMerge pull request #60109 from idryomov/wip-63184 (diff)
downloadceph-966920e063cc1fa276fbc09798779d71be51947d.tar.xz
ceph-966920e063cc1fa276fbc09798779d71be51947d.zip
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 <max.kellermann@ionos.com>
-rw-r--r--src/msg/async/ProtocolV2.cc4
-rw-r--r--src/msg/async/ProtocolV2.h4
2 files changed, 4 insertions, 4 deletions
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<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)) {
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<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);