Packets: internal pointer access optimization in ConcretePacket
tho [Mon, 6 Sep 2010 11:52:24 +0000 (11:52 +0000)]
PPI: some minor optimizations

git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1709 270642c3-0616-0410-b53a-bc976706d245

senf/PPI/Connectors.cti
senf/PPI/Connectors.hh
senf/PPI/QueueingSocketSink.ct
senf/Packets/Packet.cti
senf/Packets/Packet.hh
senf/Packets/PacketImpl.cc
senf/Packets/PacketImpl.cci
senf/Packets/PacketInterpreter.cc
senf/Packets/PacketInterpreter.hh

index 9a756b9..2b36442 100644 (file)
@@ -37,15 +37,15 @@ template <class Self, class PacketType>
 prefix_ typename senf::ppi::connector::detail::TypedInputMixin<Self,PacketType>::Type
 senf::ppi::connector::detail::TypedInputMixin<Self,PacketType>::operator()()
 {
-    return read();
+    Packet p (static_cast<Self*>(this)->InputConnector::operator()());
+    return p ? p.as<Type>() : Type();
 }
 
 template <class Self, class PacketType>
 prefix_ typename senf::ppi::connector::detail::TypedInputMixin<Self,PacketType>::Type
 senf::ppi::connector::detail::TypedInputMixin<Self,PacketType>::read()
 {
-    Packet p (static_cast<Self*>(this)->InputConnector::read());
-    return p ? p.as<Type>() : Type();
+    return operator()();
 }
 
 ///////////////////////////////////////////////////////////////////////////
index 6b4cdef..41994e1 100644 (file)
@@ -670,8 +670,8 @@ namespace connector {
     class ActiveOutput : public GenericActiveOutput
     {
     public:
-        operator()(PacketType packet);  ///< Send out a packet
-        void write(PacketType packet);  ///< Alias for operator()
+        void operator()(PacketType packet); ///< Send out a packet
+        void write(PacketType packet);      ///< Alias for operator()
     };
 
     /** \brief Connector passively providing packets
@@ -690,8 +690,8 @@ namespace connector {
     class PassiveOutput : public GenericPassiveOutput
     {
     public:
-        operator()(PacketType packet);  ///< Send out a packet
-        void write(PacketType packet);  ///< Alias for operator()
+        void operator()(PacketType packet); ///< Send out a packet
+        void write(PacketType packet);      ///< Alias for operator()
     };
 
 #endif
index 2d991c6..6a1e831 100644 (file)
@@ -79,7 +79,7 @@ prefix_ senf::ppi::module::PassiveQueueingSocketSink<Writer>::PassiveQueueingSoc
 template <class Writer>
 prefix_ void senf::ppi::module::PassiveQueueingSocketSink<Writer>::write()
 {
-    PacketType p ( input.read());
+    PacketType p ( input());
     if (qAlgo_->size() > 0) {
         qAlgo_->enqueue( p);
         return;
index 0241419..902681b 100644 (file)
@@ -327,11 +327,10 @@ prefix_ senf::ConcretePacket<PacketType>::ConcretePacket(typename interpreter::p
 {}
 
 template <class PacketType>
-prefix_ typename senf::ConcretePacket<PacketType>::interpreter::ptr
-senf::ConcretePacket<PacketType>::ptr()
+prefix_ typename senf::ConcretePacket<PacketType>::interpreter * senf::ConcretePacket<PacketType>::ptr()
     const
 {
-    return boost::static_pointer_cast< PacketInterpreter<PacketType> >(Packet::ptr());
+    return static_cast< PacketInterpreter<PacketType> *>( Packet::ptr().get());
 }
 
 ///////////////////////////////cti.e///////////////////////////////////////
index 7d31942..090cd66 100644 (file)
@@ -405,7 +405,7 @@ namespace senf {
                                              when using a packet in a boolean context. */
 
         void finalizeThis();            ///< Update calculated fields
-                                        /**< The finalize() fammily of members will update
+                                        /**< The finalize() family of members will update
                                              calculated packet fields: checksums, size fields and so
                                              on. This includes any field, which can be set from
                                              other information in the packet. Each concrete packet
@@ -420,7 +420,7 @@ namespace senf {
 
         template <class Other>
         void finalizeTo();              ///< Update calculated fields
-                                        /**< The finalize() fammily of members will update
+                                        /**< The finalize() family of members will update
                                              calculated packet fields: checksums, size fields and so
                                              on. This includes any field, which can be set from
                                              other information in the packet. Each concrete packet
@@ -439,7 +439,7 @@ namespace senf {
                                              \endcode */
 
         void finalizeTo(Packet const & other);  ///< Update calculated fields
-                                        /**< The finalize() fammily of members will update
+                                        /**< The finalize() family of members will update
                                              calculated packet fields: checksums, size fields and so
                                              on. This includes any field, which can be set from
                                              other information in the packet. Each concrete packet
@@ -762,7 +762,7 @@ namespace senf {
 
         ConcretePacket(typename interpreter::ptr const & packet_);
 
-        typename interpreter::ptr ptr() const;
+        interpreter * ptr() const;
 
         friend class Packet;
         friend class PacketInterpreter<PacketType>;
index b1c9791..0c38d46 100644 (file)
@@ -167,6 +167,18 @@ prefix_ void * senf::detail::PacketImpl::complexAnnotation(AnnotationRegistry::k
 ///////////////////////////////////////////////////////////////////////////
 // senf::detail::AnnotationRegistry
 
+prefix_ void senf::detail::AnnotationRegistry::dump(key_type key, std::ostream & os,
+                                                    void * annotation)
+    const
+{
+    Registry::const_iterator i (registry_.find(key));
+    if (i != registry_.end()) {
+        os << fieldName(i->second->v_name());
+        i->second->v_dump(os, annotation);
+        os << "\n";
+    }
+}
+
 prefix_ void senf::detail::AnnotationRegistry::dumpRegistrations(std::ostream & os)
 {
     boost::format fmt ("%-56.56s  %-4.4s  %-7.7s  %5d\n");
index 70ac003..2cc4f67 100644 (file)
 ///////////////////////////////////////////////////////////////////////////
 // senf::detail::AnnotationRegistry
 
-prefix_ void senf::detail::AnnotationRegistry::dump(key_type key, std::ostream & os,
-                                                    void * annotation)
-    const
-{
-    Registry::const_iterator i (registry_.find(key));
-    if (i != registry_.end()) {
-        os << fieldName(i->second->v_name());
-        i->second->v_dump(os, annotation);
-        os << "\n";
-    }
-}
-
 prefix_ std::string senf::detail::AnnotationRegistry::name(key_type key)
     const
 {
index 77627d3..cb94b8d 100644 (file)
@@ -110,7 +110,7 @@ prefix_ void senf::PacketInterpreterBase::add_ref()
     intrusive_refcount_t<PacketInterpreterBase>::add_ref();
 }
 
-prefix_ bool senf::PacketInterpreterBase::release()
+prefix_ void senf::PacketInterpreterBase::release()
 {
     if (impl_ && refcount()==1)
         // This call will set impl_ to 0 if we just removed the last reference ...
index d8fd813..fa9ed46 100644 (file)
@@ -214,7 +214,7 @@ namespace senf {
         // reference/memory management. Only to be called by intrusive_refcount_t.
 
         void add_ref();
-        bool release();
+        void release();
 
         // containment management. Only to be called by PacketImpl.