From: Max Kellermann Date: Wed, 16 Oct 2024 17:53:20 +0000 (+0200) Subject: include/CompatSet: use std::string_view in struct Feature X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5a45cd213e52fc3dabcccc5ba85706205468a732;p=ceph.git include/CompatSet: use std::string_view in struct Feature 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 --- diff --git a/src/include/CompatSet.h b/src/include/CompatSet.h index 9d63edc55a9..24cadd6ab57 100644 --- a/src/include/CompatSet.h +++ b/src/include/CompatSet.h @@ -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 {