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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user