From e5697f0c2c5daf3264e73bd96e6d7fdc9da68b03 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 26 Jul 2015 19:44:06 +0300 Subject: [PATCH] Remove ByteTagList::IsDirty{Start,End} These functions are only used once and do not save time. Both functions iterate over the whole list just to prevent iterating over the whole list if they return false. As traversing the list is required in any case, these functions can be removed. --- src/network/model/byte-tag-list.cc | 52 ++---------------------------- src/network/model/byte-tag-list.h | 13 -------- 2 files changed, 2 insertions(+), 63 deletions(-) diff --git a/src/network/model/byte-tag-list.cc b/src/network/model/byte-tag-list.cc index 26d9bf6d6..72c3f02d9 100644 --- a/src/network/model/byte-tag-list.cc +++ b/src/network/model/byte-tag-list.cc @@ -252,46 +252,10 @@ ByteTagList::Begin (int32_t offsetStart, int32_t offsetEnd) const } } -bool -ByteTagList::IsDirtyAtEnd (int32_t appendOffset) -{ - NS_LOG_FUNCTION (this << appendOffset); - ByteTagList::Iterator i = BeginAll (); - while (i.HasNext ()) - { - ByteTagList::Iterator::Item item = i.Next (); - if (item.end > appendOffset) - { - return true; - } - } - return false; -} - -bool -ByteTagList::IsDirtyAtStart (int32_t prependOffset) -{ - NS_LOG_FUNCTION (this << prependOffset); - ByteTagList::Iterator i = BeginAll (); - while (i.HasNext ()) - { - ByteTagList::Iterator::Item item = i.Next (); - if (item.start < prependOffset) - { - return true; - } - } - return false; -} - void ByteTagList::AddAtEnd (int32_t adjustment, int32_t appendOffset) { NS_LOG_FUNCTION (this << adjustment << appendOffset); - if (adjustment == 0 && !IsDirtyAtEnd (appendOffset)) - { - return; - } ByteTagList list; ByteTagList::Iterator i = BeginAll (); while (i.HasNext ()) @@ -304,14 +268,10 @@ ByteTagList::AddAtEnd (int32_t adjustment, int32_t appendOffset) { continue; } - else if (item.start < appendOffset && item.end > appendOffset) + if (item.end > appendOffset) { item.end = appendOffset; } - else - { - // nothing to do. - } TagBuffer buf = list.Add (item.tid, item.size, item.start, item.end); buf.CopyFrom (item.buf); } @@ -322,10 +282,6 @@ void ByteTagList::AddAtStart (int32_t adjustment, int32_t prependOffset) { NS_LOG_FUNCTION (this << adjustment << prependOffset); - if (adjustment == 0 && !IsDirtyAtStart (prependOffset)) - { - return; - } ByteTagList list; ByteTagList::Iterator i = BeginAll (); while (i.HasNext ()) @@ -338,14 +294,10 @@ ByteTagList::AddAtStart (int32_t adjustment, int32_t prependOffset) { continue; } - else if (item.end > prependOffset && item.start < prependOffset) + if (item.start < prependOffset) { item.start = prependOffset; } - else - { - // nothing to do. - } TagBuffer buf = list.Add (item.tid, item.size, item.start, item.end); buf.CopyFrom (item.buf); } diff --git a/src/network/model/byte-tag-list.h b/src/network/model/byte-tag-list.h index e8a5463c0..4511074b7 100644 --- a/src/network/model/byte-tag-list.h +++ b/src/network/model/byte-tag-list.h @@ -226,19 +226,6 @@ private: void AddAtStart (int32_t adjustment, int32_t prependOffset); private: - /** - * \brief Check that all offsets are smaller than appendOffset - * \param appendOffset the append offset to check - * \returns true if the check is false - */ - bool IsDirtyAtEnd (int32_t appendOffset); - /** - * \brief Check that all offsets are bigger than prependOffset - * \param prependOffset the prepend offset to check - * \returns true if the check is false - */ - bool IsDirtyAtStart (int32_t prependOffset); - /** * \brief Returns an iterator pointing to the very first tag in this list. *