mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Replace swap with move where appropriate
This commit is contained in:
parent
6591c59504
commit
20b048fb08
@ -362,13 +362,10 @@ std::uint64_t SoundFileReaderFlac::read(std::int16_t* samples, std::uint64_t max
|
|||||||
if (left > maxCount)
|
if (left > maxCount)
|
||||||
{
|
{
|
||||||
// There are more leftovers than needed
|
// There are more leftovers than needed
|
||||||
std::copy(m_clientData.leftovers.begin(),
|
const auto signedMaxCount = static_cast<std::vector<std::int16_t>::difference_type>(maxCount);
|
||||||
m_clientData.leftovers.begin() + static_cast<std::vector<std::int16_t>::difference_type>(maxCount),
|
std::copy(m_clientData.leftovers.begin(), m_clientData.leftovers.begin() + signedMaxCount, samples);
|
||||||
samples);
|
m_clientData.leftovers = std::vector<std::int16_t>(m_clientData.leftovers.begin() + signedMaxCount,
|
||||||
std::vector<std::int16_t> leftovers(m_clientData.leftovers.begin() +
|
|
||||||
static_cast<std::vector<std::int16_t>::difference_type>(maxCount),
|
|
||||||
m_clientData.leftovers.end());
|
m_clientData.leftovers.end());
|
||||||
m_clientData.leftovers.swap(leftovers);
|
|
||||||
return maxCount;
|
return maxCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -154,7 +155,7 @@ void Image::resize(Vector2u size, Color color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Commit the new pixel buffer
|
// Commit the new pixel buffer
|
||||||
m_pixels.swap(newPixels);
|
m_pixels = std::move(newPixels);
|
||||||
|
|
||||||
// Assign the new size
|
// Assign the new size
|
||||||
m_size = size;
|
m_size = size;
|
||||||
@ -179,7 +180,7 @@ void Image::resize(Vector2u size, const std::uint8_t* pixels)
|
|||||||
std::vector<std::uint8_t> newPixels(pixels, pixels + size.x * size.y * 4);
|
std::vector<std::uint8_t> newPixels(pixels, pixels + size.x * size.y * 4);
|
||||||
|
|
||||||
// Commit the new pixel buffer
|
// Commit the new pixel buffer
|
||||||
m_pixels.swap(newPixels);
|
m_pixels = std::move(newPixels);
|
||||||
|
|
||||||
// Assign the new size
|
// Assign the new size
|
||||||
m_size = size;
|
m_size = size;
|
||||||
|
Loading…
Reference in New Issue
Block a user