avoid stupid string allocation all the time.
1.1 --- a/utils/bench-packets.cc Wed May 07 13:47:19 2008 -0700
1.2 +++ b/utils/bench-packets.cc Wed May 07 15:01:45 2008 -0700
1.3 @@ -22,6 +22,7 @@
1.4 #include "ns3/packet-metadata.h"
1.5 #include <iostream>
1.6 #include <sstream>
1.7 +#include <string>
1.8
1.9 using namespace ns3;
1.10
1.11 @@ -39,6 +40,7 @@
1.12 virtual void Serialize (Buffer::Iterator start) const;
1.13 virtual uint32_t Deserialize (Buffer::Iterator start);
1.14 private:
1.15 + static std::string GetTypeName (void);
1.16 bool m_ok;
1.17 };
1.18
1.19 @@ -55,12 +57,19 @@
1.20 }
1.21
1.22 template <int N>
1.23 +std::string
1.24 +BenchHeader<N>::GetTypeName (void)
1.25 +{
1.26 + std::ostringstream oss;
1.27 + oss << "ns3::BenchHeader<" << N << ">";
1.28 + return oss.str ();
1.29 +}
1.30 +
1.31 +template <int N>
1.32 TypeId
1.33 BenchHeader<N>::GetTypeId (void)
1.34 {
1.35 - std::ostringstream oss;
1.36 - oss << "ns3::BenchHeader<"<<N<<">";
1.37 - static TypeId tid = TypeId (oss.str ().c_str ())
1.38 + static TypeId tid = TypeId (GetTypeName ().c_str ())
1.39 .SetParent<Header> ()
1.40 ;
1.41 return tid;