Skip to content

Commit 9441e9a

Browse files
committed
common/options: pass name as rvalue reference
Signed-off-by: Max Kellermann <[email protected]>
1 parent d29434c commit 9441e9a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/common/options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ struct Option {
207207
typedef std::function<int(std::string *, std::string *)> validator_fn_t;
208208
validator_fn_t validator;
209209

210-
Option(std::string const &name, type_t t, level_t l)
211-
: name(name), type(t), level(l)
210+
Option(std::string &&name, type_t t, level_t l)
211+
: name(std::move(name)), type(t), level(l)
212212
{
213213
// While value_t is nullable (via std::monostate), we don't ever
214214
// want it set that way in an Option instance: within an instance,

src/mon/ConfigMap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ int ConfigMap::add_option(
266266
ldout(cct, 10) << __func__ << " unrecognized option '" << name << "'" << dendl;
267267
stray_options.push_back(
268268
std::unique_ptr<Option>(
269-
new Option(name, Option::TYPE_STR, Option::LEVEL_UNKNOWN)));
269+
new Option(std::string{name}, Option::TYPE_STR, Option::LEVEL_UNKNOWN)));
270270
opt = stray_options.back().get();
271271
}
272272

src/mon/MgrMonitor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap)
215215
string name = string("mgr/") + i.name + "/" + j.second.name;
216216
auto p = mgr_module_options.emplace(
217217
name,
218-
Option(name, static_cast<Option::type_t>(j.second.type),
218+
Option(std::string{name}, static_cast<Option::type_t>(j.second.type),
219219
static_cast<Option::level_t>(j.second.level)));
220220
Option& opt = p.first->second;
221221
opt.set_flags(static_cast<Option::flag_t>(j.second.flags));

0 commit comments

Comments
 (0)