mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +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)
|
||||
{
|
||||
const std::lock_guard lock(m_mutex);
|
||||
const std::size_t oldSize = m_samples.size();
|
||||
m_samples.resize(oldSize + sampleCount);
|
||||
std::memcpy(&(m_samples[oldSize]),
|
||||
static_cast<const char*>(packet.getData()) + 1,
|
||||
sampleCount * sizeof(std::int16_t));
|
||||
const auto* begin = static_cast<const char*>(packet.getData()) + 1;
|
||||
const auto* end = begin + sampleCount * sizeof(std::int16_t);
|
||||
m_samples.insert(m_samples.end(), begin, end);
|
||||
}
|
||||
}
|
||||
else if (id == serverEndOfStream)
|
||||
|
@ -66,9 +66,9 @@ void Packet::append(const void* data, std::size_t sizeInBytes)
|
||||
{
|
||||
if (data && (sizeInBytes > 0))
|
||||
{
|
||||
const std::size_t start = m_data.size();
|
||||
m_data.resize(start + sizeInBytes);
|
||||
std::memcpy(&m_data[start], data, sizeInBytes);
|
||||
const auto* begin = reinterpret_cast<const std::byte*>(data);
|
||||
const auto* end = begin + sizeInBytes;
|
||||
m_data.insert(m_data.end(), begin, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user