Skip to content

Commit 895691e

Browse files
committed
common/config: make legacy_values static
This field is `const` and we need only one global instance, and not one copy per `md_config_t` instance. Signed-off-by: Max Kellermann <[email protected]>
1 parent 41ebce3 commit 895691e

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/common/config.cc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ const char *CEPH_CONF_FILE_DEFAULT = "$data_dir/config,/etc/ceph/$cluster.conf,$
6868
#define _STR(x) #x
6969
#define STRINGIFY(x) _STR(x)
7070

71+
// Populate list of legacy_values according to the OPTION() definitions
72+
// Note that this is just setting up our map of name->member ptr. The
73+
// default values etc will get loaded in along with new-style data,
74+
// as all loads write to both the values map, and the legacy
75+
// members if present.
76+
const std::map<std::string_view, md_config_t::member_ptr_t> md_config_t::legacy_values = {
77+
#define OPTION(name, type) \
78+
{STRINGIFY(name), &ConfigValues::name},
79+
#define SAFE_OPTION(name, type) OPTION(name, type)
80+
#include "options/legacy_config_opts.h"
81+
#undef OPTION
82+
#undef SAFE_OPTION
83+
};
84+
7185
const char *ceph_conf_level_name(int level)
7286
{
7387
switch (level) {
@@ -170,20 +184,6 @@ md_config_t::md_config_t(ConfigValues& values,
170184
schema.emplace(opt.name, opt);
171185
}
172186

173-
// Populate list of legacy_values according to the OPTION() definitions
174-
// Note that this is just setting up our map of name->member ptr. The
175-
// default values etc will get loaded in along with new-style data,
176-
// as all loads write to both the values map, and the legacy
177-
// members if present.
178-
legacy_values = {
179-
#define OPTION(name, type) \
180-
{STRINGIFY(name), &ConfigValues::name},
181-
#define SAFE_OPTION(name, type) OPTION(name, type)
182-
#include "options/legacy_config_opts.h"
183-
#undef OPTION
184-
#undef SAFE_OPTION
185-
};
186-
187187
validate_schema();
188188

189189
// Validate default values from the schema

src/common/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct md_config_t {
9191
/*
9292
* Mapping from legacy config option names to class members
9393
*/
94-
std::map<std::string_view, member_ptr_t> legacy_values;
94+
static const std::map<std::string_view, member_ptr_t> legacy_values;
9595

9696
/**
9797
* The configuration schema, in the form of Option objects describing

0 commit comments

Comments
 (0)