avoid doing the work twice.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 08 May 2008 11:22:25 -0700
changeset 3056 d4bb2f7687d1
parent 3055 c908e1a82801
child 3057 e26ab7b61c7c
avoid doing the work twice.
src/common/tag-list.cc
src/common/tag-list.h
--- a/src/common/tag-list.cc	Thu May 08 11:16:32 2008 -0700
+++ b/src/common/tag-list.cc	Thu May 08 11:22:25 2008 -0700
@@ -64,11 +64,11 @@
 TagList::Iterator::Next (void)
 {
   NS_ASSERT (HasNext ());
-  struct Item item = Item (TagBuffer (m_current, m_end));
-  item.tid.SetUid (item.buf.ReadU32 ());
-  item.size = item.buf.ReadU32 ();
-  item.start = item.buf.ReadU32 ();
-  item.end = item.buf.ReadU32 ();
+  struct Item item = Item (TagBuffer (m_current+16, m_end));
+  item.tid.SetUid (m_nextTid);
+  item.size = m_nextSize;
+  item.start = m_nextStart;
+  item.end = m_nextEnd;
   item.start = std::max (item.start, m_offsetStart);
   item.end = std::min (item.end, m_offsetEnd);
   m_current += 4 + 4 + 4 + 4 + item.size;
@@ -81,14 +81,14 @@
 {
   while (m_current < m_end)
     {
-      struct Item item = Item (TagBuffer (m_current, m_end));
-      item.tid.SetUid (item.buf.ReadU32 ());
-      item.size = item.buf.ReadU32 ();
-      item.start = item.buf.ReadU32 ();
-      item.end = item.buf.ReadU32 ();
-      if (item.start > m_offsetEnd || item.end < m_offsetStart)
+      TagBuffer buf = TagBuffer (m_current, m_end);
+      m_nextTid = buf.ReadU32 ();
+      m_nextSize = buf.ReadU32 ();
+      m_nextStart = buf.ReadU32 ();
+      m_nextEnd = buf.ReadU32 ();
+      if (m_nextStart > m_offsetEnd || m_nextEnd < m_offsetStart)
 	{
-	  m_current += 4 + 4 + 4 + 4 + item.size;
+	  m_current += 4 + 4 + 4 + 4 + m_nextSize;
 	}
       else
 	{
--- a/src/common/tag-list.h	Thu May 08 11:16:32 2008 -0700
+++ b/src/common/tag-list.h	Thu May 08 11:22:25 2008 -0700
@@ -57,6 +57,10 @@
     uint8_t *m_end;
     uint32_t m_offsetStart;
     uint32_t m_offsetEnd;
+    uint32_t m_nextTid;
+    uint32_t m_nextSize;
+    uint32_t m_nextStart;
+    uint32_t m_nextEnd;
   };
 
   TagList ();