From: tho Date: Tue, 3 Aug 2010 10:40:43 +0000 (+0000) Subject: Packets: optimized intrusive_ptr access; optimized PacketTypeMixin member parameters X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a0b6f53e5c464c6b84fed30a67fcce32da81012d;p=senf.git Packets: optimized intrusive_ptr access; optimized PacketTypeMixin member parameters git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1657 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/Packet.cci b/senf/Packets/Packet.cci index 9773af8..54b65f1 100644 --- a/senf/Packets/Packet.cci +++ b/senf/Packets/Packet.cci @@ -34,11 +34,11 @@ // protected members -prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr packet) +prefix_ senf::Packet::Packet(PacketInterpreterBase::ptr const & packet) : packet_(packet) {} -prefix_ senf::PacketInterpreterBase::ptr senf::Packet::ptr() +prefix_ senf::PacketInterpreterBase::ptr const & senf::Packet::ptr() const { SENF_ASSERT(packet_, "Invalid operation (dereferencing) on in-valid() Packet"); diff --git a/senf/Packets/Packet.cti b/senf/Packets/Packet.cti index 9ba8a4b..ecb8baa 100644 --- a/senf/Packets/Packet.cti +++ b/senf/Packets/Packet.cti @@ -37,7 +37,7 @@ // conversion constructors template -prefix_ senf::Packet::Packet(ConcretePacket packet) +prefix_ senf::Packet::Packet(ConcretePacket const & packet) : packet_(packet.ptr()) {} @@ -312,7 +312,7 @@ senf::ConcretePacket::operator->() // private members template -prefix_ senf::ConcretePacket::ConcretePacket(typename interpreter::ptr packet_) +prefix_ senf::ConcretePacket::ConcretePacket(typename interpreter::ptr const & packet_) : Packet(packet_) {} diff --git a/senf/Packets/Packet.hh b/senf/Packets/Packet.hh index db53195..25d0f56 100644 --- a/senf/Packets/Packet.hh +++ b/senf/Packets/Packet.hh @@ -171,7 +171,8 @@ namespace senf { // conversion constructors template - Packet(ConcretePacket packet); ///< Copy-construct Packet from ConcretePacket + Packet(ConcretePacket const & packet); + ///< Copy-construct Packet from ConcretePacket /**< This constructor allows to convert an arbitrary ConcretePacket into a general Packet, loosing the protocol specific interface. */ @@ -489,9 +490,9 @@ namespace senf { ///@} protected: - explicit Packet(PacketInterpreterBase::ptr packet); + explicit Packet(PacketInterpreterBase::ptr const & packet); - PacketInterpreterBase::ptr ptr() const; + PacketInterpreterBase::ptr const & ptr() const; private: Packet checkNext() const; @@ -752,7 +753,7 @@ namespace senf { private: typedef PacketInterpreter interpreter; - ConcretePacket(typename interpreter::ptr packet_); + ConcretePacket(typename interpreter::ptr const & packet_); typename interpreter::ptr ptr() const; diff --git a/senf/Packets/PacketParser.hh b/senf/Packets/PacketParser.hh index 93311c0..56b20d9 100644 --- a/senf/Packets/PacketParser.hh +++ b/senf/Packets/PacketParser.hh @@ -296,7 +296,7 @@ namespace senf { senf::safe_data_iterator safe_i_; mutable PacketParserBase const * parser_; - ParserProtector( PacketParserBase const * parser); + ParserProtector(PacketParserBase const * parser); ParserProtector(ParserProtector const & other_); ~ParserProtector(); }; diff --git a/senf/Packets/PacketType.ct b/senf/Packets/PacketType.ct index 2358810..ab69324 100644 --- a/senf/Packets/PacketType.ct +++ b/senf/Packets/PacketType.ct @@ -35,13 +35,13 @@ template prefix_ senf::PacketInterpreterBase::optional_range -senf::PacketTypeMixin::nextPacketRange(Packet const & p) +senf::PacketTypeMixin::nextPacketRange(ConcretePacket const & p) { typename Self::size_type sz (Self::initHeadSize()); ///\idea This if condition could be replaced with a compile time switch by checking, wether /// (the function address) Self::initHeadSize is different from PacketTypeBase::initHeadSize if (sz == PacketTypeBase::size_type(-1)) { - typename Self::size_type headsz (bytes(p.as< ConcretePacket >().parser())); + typename Self::size_type headsz (bytes(p.parser())); return p.data().size() < headsz ? PacketTypeBase::no_range() : PacketInterpreterBase::optional_range( diff --git a/senf/Packets/PacketType.cti b/senf/Packets/PacketType.cti index fe4bdce..4caed76 100644 --- a/senf/Packets/PacketType.cti +++ b/senf/Packets/PacketType.cti @@ -46,7 +46,7 @@ prefix_ senf::PacketTypeBase::factory_t senf::PacketTypeBase::factory() template prefix_ senf::PacketInterpreterBase::optional_range -senf::PacketTypeMixin::nextPacketRange(Packet const & p) +senf::PacketTypeMixin::nextPacketRange(ConcretePacket const & p) { // Call the member defined in the specialization below return PacketTypeMixin::nextPacketRange(p); @@ -54,11 +54,11 @@ senf::PacketTypeMixin::nextPacketRange(Packet const & p) template prefix_ senf::PacketInterpreterBase::factory_t -senf::PacketTypeMixin::nextPacketType(Packet const & p) +senf::PacketTypeMixin::nextPacketType(ConcretePacket const & p) { if (p.data().size() < Self::initSize()) return Self::no_factory(); - return lookup( Self::nextPacketKey(p.as< ConcretePacket >()) ); + return lookup( Self::nextPacketKey(p) ); } template @@ -68,9 +68,9 @@ prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin -prefix_ void senf::PacketTypeMixin::init(Packet const & p) +prefix_ void senf::PacketTypeMixin::init(ConcretePacket const & p) { - p.as< ConcretePacket >()->init(); + p->init(); } template @@ -98,9 +98,9 @@ prefix_ senf::PacketInterpreterBase::size_type senf::PacketTypeMixin: } template -prefix_ void senf::PacketTypeMixin::init(Packet const & p) +prefix_ void senf::PacketTypeMixin::init(ConcretePacket const & p) { - p.as< ConcretePacket >()->init(); + p->init(); } ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/senf/Packets/PacketType.hh b/senf/Packets/PacketType.hh index c6b4cfc..2c6fd01 100644 --- a/senf/Packets/PacketType.hh +++ b/senf/Packets/PacketType.hh @@ -333,10 +333,10 @@ namespace senf { ///\name PacketType interface implementation ///@{ - static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p); - static PacketInterpreterBase::factory_t nextPacketType (Packet const & p); + static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket const & p); + static PacketInterpreterBase::factory_t nextPacketType (ConcretePacket const & p); static PacketInterpreterBase::size_type initSize (); - static void init (Packet const & p); + static void init (ConcretePacket const & p); ///@} }; @@ -347,9 +347,9 @@ namespace senf { class PacketTypeMixin { public: - static PacketInterpreterBase::optional_range nextPacketRange (Packet const & p); + static PacketInterpreterBase::optional_range nextPacketRange (ConcretePacket const & p); static PacketInterpreterBase::size_type initSize (); - static void init (Packet const & p); + static void init (ConcretePacket const & p); }; # endif