avoid allocating strings all the time.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 11 Sep 2007 10:35:56 +0200
changeset 1323 08174b13d76f
parent 1322 b6a4885a92df
child 1324 968f98557540
child 1421 df273f351a4c
child 1484 f68a774a0d22
avoid allocating strings all the time.
utils/bench-packets.cc
--- a/utils/bench-packets.cc	Tue Sep 11 08:27:27 2007 +0200
+++ b/utils/bench-packets.cc	Tue Sep 11 10:35:56 2007 +0200
@@ -35,7 +35,7 @@
 
   static uint32_t GetUid (void);
 
-  std::string GetName (void) const;
+  static std::string GetName (void);
   void Print (std::ostream &os) const;
   uint32_t GetSerializedSize (void) const;
   void Serialize (Buffer::Iterator start) const;
@@ -60,18 +60,16 @@
 uint32_t 
 BenchHeader<N>::GetUid (void)
 {
-  std::ostringstream oss;
-  oss << "BenchHeader" << N;
-  static uint32_t uid = AllocateUid<BenchHeader<N> > (oss.str ());
+  static uint32_t uid = AllocateUid<BenchHeader<N> > (GetName ());
   return uid;
 }
 
 template <int N>
 std::string 
-BenchHeader<N>::GetName (void) const
+BenchHeader<N>::GetName (void)
 {
   std::ostringstream oss;
-  oss << N;
+  oss << "BenchHeader" << N;
   return oss.str ();
 }