]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: change the element type of lists to "const char*" 16482/head
authorKefu Chai <kchai@redhat.com>
Fri, 21 Jul 2017 13:03:41 +0000 (21:03 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 26 Jul 2017 16:09:52 +0000 (00:09 +0800)
there lists holds constant string literals. and they are not changeable
at runtime. so make std::list<const char*> for smaller memory foot
print.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/options.cc
src/common/options.h

index 4385f83f52a6efc3309701a88817166989ffcfd7..1f268c944d3757c84bb0cf177e02c2bf5f5839ca 100644 (file)
@@ -5529,7 +5529,7 @@ static std::vector<Option> build_options()
 {
   std::vector<Option> result = global_options;
 
-  auto ingest = [&result](std::vector<Option> &options, const std::string &svc) {
+  auto ingest = [&result](std::vector<Option> &options, const char* svc) {
     for (const auto &o_in : options) {
       Option o(o_in);
       o.add_service(svc);
index 9044d975dd330cf630ad99955e153ba8ad1067af..770fa53144147230dc37bf3df6387793234bff93 100644 (file)
@@ -79,16 +79,16 @@ struct Option {
   // Additionally: "common" for settings that exist in any Ceph code.  Do
   // not use common for settings that are just shared some places: for those
   // places, list them.
-  std::list<std::string> services;
+  std::list<const char*> services;
 
   // Topics like:
   // "service": a catchall for the boring stuff like log/asok paths.
   // "network"
   // "performance": a setting that may need adjustment depending on
   //                environment/workload to get best performance.
-  std::list<std::string> tags;
+  std::list<const char*> tags;
 
-  std::list<std::string> see_also;
+  std::list<const char*> see_also;
 
   value_t min, max;
   std::list<std::string> enum_allowed;
@@ -192,7 +192,7 @@ struct Option {
     return *this;
   }
   Option& add_tag(std::initializer_list<const char*> ts) {
-    tags.insert(tags.end(), ts.begin(), ts.end());
+    tags.insert(tags.end(), ts);
     return *this;
   }
   Option& add_service(const char* service) {
@@ -200,7 +200,7 @@ struct Option {
     return *this;
   }
   Option& add_service(std::initializer_list<const char*> ss) {
-    services.insert(services.end(), ss.begin(), ss.end());
+    services.insert(services.end(), ss);
     return *this;
   }
   Option& add_see_also(const char* t) {
@@ -208,7 +208,7 @@ struct Option {
     return *this;
   }
   Option& add_see_also(std::initializer_list<const char*> ts) {
-    see_also.insert(see_also.end(), ts.begin(), ts.end());
+    see_also.insert(see_also.end(), ts);
     return *this;
   }
   Option& set_description(const char* new_desc) {