Skip to content

Commit

Permalink
Traktor: Opimized AlignedVector serialization, using less branches in…
Browse files Browse the repository at this point in the history
… inner loop.
  • Loading branch information
apistol78 committed Feb 22, 2025
1 parent 5cc465d commit a817be5
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions code/Core/Serialization/MemberAlignedVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,29 @@ class MemberAlignedVector : public MemberArray

virtual void read(ISerializer& s, size_t count) const override final
{
for (size_t i = 0; i < count; ++i)
const size_t from = m_index;
const size_t to = m_index + count;

if (to < m_ref.size())
{
for (size_t i = from; i < to; ++i)
s >> ValueMember(L"item", m_ref[i]);
}
else if (m_ref.size() == 0)
{
if (m_index < m_ref.size())
s >> ValueMember(L"item", m_ref[m_index]);
else
for (size_t i = from; i < to; ++i)
s >> ValueMember(L"item", m_ref.push_back());

++m_index;
}
else
{
for (size_t i = from; i < to; ++i)
if (i < m_ref.size())
s >> ValueMember(L"item", m_ref[i]);
else
s >> ValueMember(L"item", m_ref.push_back());
}

m_index = to;
}

virtual void write(ISerializer& s, size_t count) const override final
Expand Down

0 comments on commit a817be5

Please sign in to comment.