mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 14:21:04 +08:00
Replace std::memcpy
with a more expressive alternative
This commit is contained in:
parent
f588589089
commit
b16114fa23
@ -133,11 +133,9 @@ private:
|
|||||||
// (so we protect any operation on it with the mutex)
|
// (so we protect any operation on it with the mutex)
|
||||||
{
|
{
|
||||||
const std::lock_guard lock(m_mutex);
|
const std::lock_guard lock(m_mutex);
|
||||||
const std::size_t oldSize = m_samples.size();
|
const auto* begin = static_cast<const char*>(packet.getData()) + 1;
|
||||||
m_samples.resize(oldSize + sampleCount);
|
const auto* end = begin + sampleCount * sizeof(std::int16_t);
|
||||||
std::memcpy(&(m_samples[oldSize]),
|
m_samples.insert(m_samples.end(), begin, end);
|
||||||
static_cast<const char*>(packet.getData()) + 1,
|
|
||||||
sampleCount * sizeof(std::int16_t));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (id == serverEndOfStream)
|
else if (id == serverEndOfStream)
|
||||||
|
@ -66,9 +66,9 @@ void Packet::append(const void* data, std::size_t sizeInBytes)
|
|||||||
{
|
{
|
||||||
if (data && (sizeInBytes > 0))
|
if (data && (sizeInBytes > 0))
|
||||||
{
|
{
|
||||||
const std::size_t start = m_data.size();
|
const auto* begin = reinterpret_cast<const std::byte*>(data);
|
||||||
m_data.resize(start + sizeInBytes);
|
const auto* end = begin + sizeInBytes;
|
||||||
std::memcpy(&m_data[start], data, sizeInBytes);
|
m_data.insert(m_data.end(), begin, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user