Skip to content

Commit

Permalink
[core] Minor refactor of CSndLossList::insert()
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored and rndi committed Nov 29, 2019
1 parent f9ac379 commit 31ffa4f
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions srtcore/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,40 +213,38 @@ int CSndLossList::insert(int32_t seqno1, int32_t seqno2)
return 0;
}

// coalesce with next node. E.g., [3, 7], ..., [6, 9] becomes [3, 9]
// coalesce with next node. E.g., [3, 7], ..., [6, 9] becomes [3, 9]
while ((-1 != m_caSeq[loc].next) && (-1 != m_caSeq[loc].data2))
{
int i = m_caSeq[loc].next;
const int i = m_caSeq[loc].next;

if (CSeqNo::seqcmp(m_caSeq[i].data1, CSeqNo::incseq(m_caSeq[loc].data2)) <= 0)
if (CSeqNo::seqcmp(m_caSeq[i].data1, CSeqNo::incseq(m_caSeq[loc].data2)) > 0)
break;

// coalesce if there is overlap
if (-1 != m_caSeq[i].data2)
{
// coalesce if there is overlap
if (-1 != m_caSeq[i].data2)
if (CSeqNo::seqcmp(m_caSeq[i].data2, m_caSeq[loc].data2) > 0)
{
if (CSeqNo::seqcmp(m_caSeq[i].data2, m_caSeq[loc].data2) > 0)
{
if (CSeqNo::seqcmp(m_caSeq[loc].data2, m_caSeq[i].data1) >= 0)
m_iLength -= CSeqNo::seqlen(m_caSeq[i].data1, m_caSeq[loc].data2);
if (CSeqNo::seqcmp(m_caSeq[loc].data2, m_caSeq[i].data1) >= 0)
m_iLength -= CSeqNo::seqlen(m_caSeq[i].data1, m_caSeq[loc].data2);

m_caSeq[loc].data2 = m_caSeq[i].data2;
}
else
m_iLength -= CSeqNo::seqlen(m_caSeq[i].data1, m_caSeq[i].data2);
m_caSeq[loc].data2 = m_caSeq[i].data2;
}
else
{
if (m_caSeq[i].data1 == CSeqNo::incseq(m_caSeq[loc].data2))
m_caSeq[loc].data2 = m_caSeq[i].data1;
else
m_iLength --;
}

m_caSeq[i].data1 = -1;
m_caSeq[i].data2 = -1;
m_caSeq[loc].next = m_caSeq[i].next;
m_iLength -= CSeqNo::seqlen(m_caSeq[i].data1, m_caSeq[i].data2);
}
else
break;
{
if (m_caSeq[i].data1 == CSeqNo::incseq(m_caSeq[loc].data2))
m_caSeq[loc].data2 = m_caSeq[i].data1;
else
m_iLength--;
}

m_caSeq[i].data1 = -1;
m_caSeq[i].data2 = -1;
m_caSeq[loc].next = m_caSeq[i].next;
}

return m_iLength - origlen;
Expand Down

0 comments on commit 31ffa4f

Please sign in to comment.