Remove ByteTagList::IsDirty{Start,End}
authorAlexander Krotov <ilabdsf@yandex.ru>
Sun, 26 Jul 2015 19:44:06 +0300
changeset 11558 68e480bb7d74
parent 11556 bdebcc180265
child 11559 cc85437fbbf7
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
src/network/model/byte-tag-list.h
--- a/src/network/model/byte-tag-list.cc	Sun Aug 02 20:44:01 2015 +0300
+++ b/src/network/model/byte-tag-list.cc	Sun Jul 26 19:44:06 2015 +0300
@@ -252,46 +252,10 @@
     }
 }
 
-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 @@
         {
           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 @@
 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 @@
         {
           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);
     }
--- a/src/network/model/byte-tag-list.h	Sun Aug 02 20:44:01 2015 +0300
+++ b/src/network/model/byte-tag-list.h	Sun Jul 26 19:44:06 2015 +0300
@@ -227,19 +227,6 @@
 
 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.
    *
    * \returns an iterator