]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/DecayCounter: un-inline operator<<
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 4 Oct 2024 19:43:21 +0000 (21:43 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Tue, 5 Aug 2025 08:28:01 +0000 (10:28 +0200)
This reduces compile times (by compiling the function only once) and
eliminates the header dependency on `common/StackStringStream.h`.

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

index 4e9e68cc1525dd200cabc1d5be3345b45bc62427..99f3de22dba2260145011ec64ccd024dfe05042c 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "DecayCounter.h"
 #include "Formatter.h"
+#include "StackStringStream.h"
 
 #include "include/encoding.h"
 
@@ -77,3 +78,11 @@ void DecayCounter::decay(double delta) const
   val = newval;
   last_decay = now;
 }
+
+std::ostream& operator<<(std::ostream& out, const DecayCounter& d) {
+  CachedStackStringStream css;
+  css->precision(2);
+  double val = d.get();
+  *css << "[C " << std::scientific << val << "]";
+  return out << css->strv();
+}
index 30570c72a306e7cbf6ac8795850e112cb72bdf14..6584b519072d1bcc14799e9b0c86dfdc8c693dfd 100644 (file)
 #define CEPH_DECAYCOUNTER_H
 
 #include "include/buffer.h"
-#include "common/StackStringStream.h"
 #include "common/ceph_time.h"
 
 #include <cmath>
 #include <list>
-#include <sstream>
 
 namespace ceph { class Formatter; }
 
@@ -126,12 +124,6 @@ inline void decode(DecayCounter &c, ceph::buffer::list::const_iterator &p) {
   c.decode(p);
 }
 
-inline std::ostream& operator<<(std::ostream& out, const DecayCounter& d) {
-  CachedStackStringStream css;
-  css->precision(2);
-  double val = d.get();
-  *css << "[C " << std::scientific << val << "]";
-  return out << css->strv();
-}
+std::ostream& operator<<(std::ostream& out, const DecayCounter& d);
 
 #endif