avoid doing the work twice.
1.1 --- a/src/common/tag-list.cc Thu May 08 11:16:32 2008 -0700
1.2 +++ b/src/common/tag-list.cc Thu May 08 11:22:25 2008 -0700
1.3 @@ -64,11 +64,11 @@
1.4 TagList::Iterator::Next (void)
1.5 {
1.6 NS_ASSERT (HasNext ());
1.7 - struct Item item = Item (TagBuffer (m_current, m_end));
1.8 - item.tid.SetUid (item.buf.ReadU32 ());
1.9 - item.size = item.buf.ReadU32 ();
1.10 - item.start = item.buf.ReadU32 ();
1.11 - item.end = item.buf.ReadU32 ();
1.12 + struct Item item = Item (TagBuffer (m_current+16, m_end));
1.13 + item.tid.SetUid (m_nextTid);
1.14 + item.size = m_nextSize;
1.15 + item.start = m_nextStart;
1.16 + item.end = m_nextEnd;
1.17 item.start = std::max (item.start, m_offsetStart);
1.18 item.end = std::min (item.end, m_offsetEnd);
1.19 m_current += 4 + 4 + 4 + 4 + item.size;
1.20 @@ -81,14 +81,14 @@
1.21 {
1.22 while (m_current < m_end)
1.23 {
1.24 - struct Item item = Item (TagBuffer (m_current, m_end));
1.25 - item.tid.SetUid (item.buf.ReadU32 ());
1.26 - item.size = item.buf.ReadU32 ();
1.27 - item.start = item.buf.ReadU32 ();
1.28 - item.end = item.buf.ReadU32 ();
1.29 - if (item.start > m_offsetEnd || item.end < m_offsetStart)
1.30 + TagBuffer buf = TagBuffer (m_current, m_end);
1.31 + m_nextTid = buf.ReadU32 ();
1.32 + m_nextSize = buf.ReadU32 ();
1.33 + m_nextStart = buf.ReadU32 ();
1.34 + m_nextEnd = buf.ReadU32 ();
1.35 + if (m_nextStart > m_offsetEnd || m_nextEnd < m_offsetStart)
1.36 {
1.37 - m_current += 4 + 4 + 4 + 4 + item.size;
1.38 + m_current += 4 + 4 + 4 + 4 + m_nextSize;
1.39 }
1.40 else
1.41 {
2.1 --- a/src/common/tag-list.h Thu May 08 11:16:32 2008 -0700
2.2 +++ b/src/common/tag-list.h Thu May 08 11:22:25 2008 -0700
2.3 @@ -57,6 +57,10 @@
2.4 uint8_t *m_end;
2.5 uint32_t m_offsetStart;
2.6 uint32_t m_offsetEnd;
2.7 + uint32_t m_nextTid;
2.8 + uint32_t m_nextSize;
2.9 + uint32_t m_nextStart;
2.10 + uint32_t m_nextEnd;
2.11 };
2.12
2.13 TagList ();