Merge pull request #796 from majestrate/master

optimize
This commit is contained in:
Jeff 2019-08-30 11:06:43 -04:00 committed by GitHub
commit eb3a4d0266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,12 +76,12 @@ namespace llarp
0}; 0};
htobe16buf(frag.data() + 2, idx); htobe16buf(frag.data() + 2, idx);
htobe64buf(frag.data() + 4, m_MsgID); htobe64buf(frag.data() + 4, m_MsgID);
if(idx + FragmentSize < m_Size) const size_t fragsz =
std::copy(m_Data.begin() + idx, m_Data.begin() + idx + FragmentSize, idx + FragmentSize < m_Size ? FragmentSize : m_Size - idx;
std::back_inserter(frag)); const auto sz = frag.size();
else frag.resize(sz + fragsz);
std::copy(m_Data.begin() + idx, m_Data.begin() + m_Size, std::copy(m_Data.begin() + idx, m_Data.begin() + idx + fragsz,
std::back_inserter(frag)); frag.begin() + sz);
const llarp_buffer_t pkt(frag); const llarp_buffer_t pkt(frag);
sendpkt(pkt); sendpkt(pkt);
} }