]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: move inner class ContextVerter out of the header
authorMax Kellermann <max.kellermann@ionos.com>
Tue, 12 Aug 2025 09:11:39 +0000 (11:11 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Wed, 15 Apr 2026 19:11:11 +0000 (21:11 +0200)
Reduce compile times by compiling these start_mon_command() overloads
only once.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mon/MonClient.cc
src/mon/MonClient.h

index 2d486b0d11a364b96b9d91de4ff8e62f4c28c829..05e73f4753bd571874dd557140b6eda9b65abb51 100644 (file)
@@ -1380,6 +1380,57 @@ void MonClient::handle_command_reply(MCommandReply *reply)
   reply->put();
 }
 
+class MonClient::ContextVerter {
+  std::string* outs;
+  ceph::bufferlist* outbl;
+  Context* onfinish;
+
+public:
+  ContextVerter(std::string* outs, ceph::bufferlist* outbl, Context* onfinish)
+    : outs(outs), outbl(outbl), onfinish(onfinish) {}
+  ~ContextVerter() = default;
+  ContextVerter(const ContextVerter&) = default;
+  ContextVerter& operator =(const ContextVerter&) = default;
+  ContextVerter(ContextVerter&&) = default;
+  ContextVerter& operator =(ContextVerter&&) = default;
+
+  void operator()(boost::system::error_code e,
+                 std::string s,
+                 ceph::bufferlist bl) {
+    if (outs)
+      *outs = std::move(s);
+    if (outbl)
+      *outbl = std::move(bl);
+    if (onfinish)
+      onfinish->complete(ceph::from_error_code(e));
+  }
+};
+
+void MonClient::start_mon_command(std::vector<std::string>&& cmd, bufferlist&& inbl,
+                                 bufferlist *outbl, std::string *outs,
+                                 Context *onfinish)
+{
+  start_mon_command(std::move(cmd), std::move(inbl),
+                   ContextVerter(outs, outbl, onfinish));
+}
+
+void MonClient::start_mon_command(int mon_rank, std::vector<std::string>&& cmd,
+                                 bufferlist&& inbl, bufferlist *outbl, std::string *outs,
+                                 Context *onfinish)
+{
+  start_mon_command(mon_rank, std::move(cmd), std::move(inbl),
+                   ContextVerter(outs, outbl, onfinish));
+}
+
+void MonClient::start_mon_command(std::string&& mon_name,  ///< mon name, with mon. prefix
+                                 std::vector<std::string>&& cmd, bufferlist&& inbl,
+                                 bufferlist *outbl, std::string *outs,
+                                 Context *onfinish)
+{
+  start_mon_command(std::move(mon_name), std::move(cmd), std::move(inbl),
+                   ContextVerter(outs, outbl, onfinish));
+}
+
 int MonClient::_cancel_mon_command(uint64_t tid)
 {
   ceph_assert(ceph_mutex_is_locked(monc_lock));
index 3b78ea62ae272a7a00683b1033a9f604e2f45720..e8e03049b2648b9703e241cbdde9c721017540ef 100644 (file)
@@ -721,52 +721,18 @@ public:
       }, consigned);
   }
 
-  class ContextVerter {
-    std::string* outs;
-    ceph::bufferlist* outbl;
-    Context* onfinish;
-
-  public:
-    ContextVerter(std::string* outs, ceph::bufferlist* outbl, Context* onfinish)
-      : outs(outs), outbl(outbl), onfinish(onfinish) {}
-    ~ContextVerter() = default;
-    ContextVerter(const ContextVerter&) = default;
-    ContextVerter& operator =(const ContextVerter&) = default;
-    ContextVerter(ContextVerter&&) = default;
-    ContextVerter& operator =(ContextVerter&&) = default;
-
-    void operator()(boost::system::error_code e,
-                   std::string&& s,
-                   ceph::bufferlist&& bl) {
-      if (outs)
-       *outs = std::move(s);
-      if (outbl)
-       *outbl = std::move(bl);
-      if (onfinish)
-       onfinish->complete(ceph::from_error_code(e));
-    }
-  };
+  class ContextVerter;
 
-  void start_mon_command(std::vector<std::string> cmd, bufferlist&& inbl,
+  void start_mon_command(std::vector<std::string>&& cmd, bufferlist&& inbl,
                         bufferlist *outbl, std::string *outs,
-                        Context *onfinish) {
-    start_mon_command(std::move(cmd), std::move(inbl),
-                     ContextVerter(outs, outbl, onfinish));
-  }
+                        Context *onfinish);
   void start_mon_command(int mon_rank, std::vector<std::string>&& cmd,
                         bufferlist&& inbl, bufferlist *outbl, std::string *outs,
-                        Context *onfinish) {
-    start_mon_command(mon_rank, std::move(cmd), std::move(inbl),
-                     ContextVerter(outs, outbl, onfinish));
-  }
+                        Context *onfinish);
   void start_mon_command(std::string&& mon_name,  ///< mon name, with mon. prefix
                         std::vector<std::string>&& cmd, bufferlist&& inbl,
                         bufferlist *outbl, std::string *outs,
-                        Context *onfinish) {
-    start_mon_command(std::move(mon_name), std::move(cmd), std::move(inbl),
-                     ContextVerter(outs, outbl, onfinish));
-  }
-
+                        Context *onfinish);
 
   // version requests
 public: