From: tho Date: Wed, 4 Aug 2010 11:03:35 +0000 (+0000) Subject: PPI: InputConnector: some minor optimization X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=aa4bfb511acb198a278caafc193ac67a9c322a13;p=senf.git PPI: InputConnector: some minor optimization git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1658 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/Connectors.cc b/senf/PPI/Connectors.cc index 0ee44f5..a6daa13 100644 --- a/senf/PPI/Connectors.cc +++ b/senf/PPI/Connectors.cc @@ -288,14 +288,16 @@ prefix_ senf::Packet senf::ppi::connector::InputConnector::operator()() { if (empty()) v_requestEvent(); - Packet p; if (! empty()) { - p = peek(); + Packet p ( queue_.back()); queue_.pop_back(); v_dequeueEvent(); + SENF_PPI_TRACE(p, "IN "); + return p; + } else { + SENF_PPI_TRACE(Packet(), "IN "); + return Packet(); } - SENF_PPI_TRACE(p, "IN "); - return p; } //////////////////////////////////////// diff --git a/senf/Packets/PacketImpl.cci b/senf/Packets/PacketImpl.cci index 34c3d1d..56e501b 100644 --- a/senf/Packets/PacketImpl.cci +++ b/senf/Packets/PacketImpl.cci @@ -59,12 +59,12 @@ prefix_ senf::detail::AnnotationP::~AnnotationP() // // * The PacketImpl destructor will *explicitly* clean-up the interpreters_ list by removing // each element from the list and deleting it if it's (intrusive) refcount is 0 -// * The PacketInterpreters use safe hooks -> they know wether they are part of a list or not +// * The PacketInterpreters use safe hooks -> they know whether they are part of a list or not // * PacketHandle has an intrusive_ptr to PacketInterpreterBase. The intrusive_ptr_add_ref // will refcount both the PacketImpl as well as the PacketInterpreterBase // * intrusive_ptr_remove will only delete the object if it's not in a container // * removing an object from the list will decrement the PacketImpl refcount accordingly -// * inserting an object into the list will incroment the PacketImpl refcount accordingly +// * inserting an object into the list will increment the PacketImpl refcount accordingly // * each PacketInterpreterBase instance holds a *raw* pointer to the PacketImpl // // The following operations change refcounts: @@ -89,7 +89,7 @@ prefix_ senf::detail::PacketImpl::PacketImpl(size_type size, byte initValue) : refcount_(0), data_(size,initValue), annotations_(AnnotationIndexerBase::maxAnnotations) {} -// rerference/memory management +// reference/memory management prefix_ void senf::detail::PacketImpl::add_ref(refcount_t n) { @@ -209,7 +209,7 @@ prefix_ void senf::detail::PacketImpl::release(refcount_t n) SENF_ASSERT(refcount_ >= n, "Internal failure: Releasing dead PacketImpl ??"); // uah ... we need to be extremely careful here. If refcount_ is n, we want to commit suicide, // however the destructor will remove all PacketInterpreters from the list and will thereby - // decrement refcount -> only decrenebt refcount_ when *not* caling delete + // decrement refcount -> only decrement refcount_ when *not* calling delete if (refcount_ == n) delete this; else diff --git a/senf/Socket/Protocols/INet/INet6Address.test.cc b/senf/Socket/Protocols/INet/INet6Address.test.cc index e342b27..f854f19 100644 --- a/senf/Socket/Protocols/INet/INet6Address.test.cc +++ b/senf/Socket/Protocols/INet/INet6Address.test.cc @@ -79,6 +79,7 @@ SENF_AUTO_UNIT_TEST(inet6Address) BOOST_CHECK_EQUAL( addr3, INet6Address::from_string("1200::21") ); BOOST_CHECK_EQUAL( INet6Address::from_inet4address(INet4Address(0x01020304)), INet6Address::from_string("::ffff:1.2.3.4") ); + BOOST_CHECK( INet6Address::from_inet4address(INet4Address(0x01020304)).inet4Mapped()); BOOST_CHECK_THROW( INet6Address::from_string("1.2.3.4"), UnknownHostnameException ); BOOST_CHECK_EQUAL( INet6Address::from_string("1.2.3.4", INet6Address::ResolveINet4), diff --git a/senf/Socket/Protocols/Raw/MACAddress.cci b/senf/Socket/Protocols/Raw/MACAddress.cci index de96558..0c1f94f 100644 --- a/senf/Socket/Protocols/Raw/MACAddress.cci +++ b/senf/Socket/Protocols/Raw/MACAddress.cci @@ -125,7 +125,7 @@ prefix_ bool senf::operator==(MACAddress const & mac, EUI64 const & eui64) { return eui64.isMACCompatible() && std::equal(eui64.begin(), eui64.begin()+3, mac.begin()) - && std::equal(eui64.begin()+5, eui64.begin()+8, mac.begin()+3); + && std::equal(eui64.begin()+5, eui64.end(), mac.begin()+3); } prefix_ bool senf::operator==(EUI64 const & eui64, MACAddress const & mac)