mirror of
https://github.com/SFML/SFML.git
synced 2025-01-19 07:45:13 +08:00
Replace raw loops with standard algorithm
This commit is contained in:
parent
c6919e28fc
commit
c89c5eae69
@ -29,6 +29,7 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Audio/Export.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -63,13 +63,11 @@ template <typename T>
|
||||
void SoundFileFactory::unregisterReader()
|
||||
{
|
||||
// Remove the instance(s) of the reader from the array of factories
|
||||
for (auto it = s_readers.begin(); it != s_readers.end(); /* noop */)
|
||||
{
|
||||
if (it->create == &priv::createReader<T>)
|
||||
it = s_readers.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
s_readers.erase(std::remove_if(s_readers.begin(),
|
||||
s_readers.end(),
|
||||
[](const ReaderFactory& readerFactory)
|
||||
{ return readerFactory.create == &priv::createReader<T>; }),
|
||||
s_readers.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -92,13 +90,11 @@ template <typename T>
|
||||
void SoundFileFactory::unregisterWriter()
|
||||
{
|
||||
// Remove the instance(s) of the writer from the array of factories
|
||||
for (auto it = s_writers.begin(); it != s_writers.end(); /* noop */)
|
||||
{
|
||||
if (it->create == &priv::createWriter<T>)
|
||||
it = s_writers.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
s_writers.erase(std::remove_if(s_writers.begin(),
|
||||
s_writers.end(),
|
||||
[](const WriterFactory& writerFactory)
|
||||
{ return writerFactory.create == &priv::createWriter<T>; }),
|
||||
s_writers.end());
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
@ -496,13 +496,10 @@ void JoystickImpl::updateConnectionsDInput()
|
||||
DIEDFL_ATTACHEDONLY);
|
||||
|
||||
// Remove devices that were not connected during the enumeration
|
||||
for (auto i = joystickList.begin(); i != joystickList.end();)
|
||||
{
|
||||
if (!i->plugged)
|
||||
i = joystickList.erase(i);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
joystickList.erase(std::remove_if(joystickList.begin(),
|
||||
joystickList.end(),
|
||||
[](const JoystickRecord& joystickRecord) { return !joystickRecord.plugged; }),
|
||||
joystickList.end());
|
||||
|
||||
if (FAILED(result))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user