]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/CompatSet: use std::string_view in struct Feature
authorMax Kellermann <max.kellermann@ionos.com>
Wed, 16 Oct 2024 17:53:20 +0000 (19:53 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Thu, 28 May 2026 06:22:35 +0000 (08:22 +0200)
Almost all callers pass a C string (in temporary Feature instances),
only `CompatSetHandler::handle()` passes a `std::string` reference.

Allocating a new `std::string` is useless overhead.  This patch
reduces the binary size by 21 kB.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/include/CompatSet.h

index 9d63edc55a90b42f4dc458e817a49bd7a4b06818..24cadd6ab57449e1429a66cbe35d4aa041c9558c 100644 (file)
@@ -29,9 +29,9 @@ struct CompatSet {
 
   struct Feature {
     uint64_t id;
-    std::string name;
+    std::string_view name;
 
-    Feature(uint64_t _id, const std::string& _name) : id(_id), name(_name) {}
+    constexpr Feature(uint64_t _id, const std::string_view _name) : id(_id), name(_name) {}
   };
 
   class FeatureSet {