Replace raw loops with standard algorithm

This commit is contained in:
Chris Thrasher 2023-11-13 16:27:05 -07:00
parent c6919e28fc
commit c89c5eae69
3 changed files with 15 additions and 21 deletions

View File

@ -29,6 +29,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <algorithm>
#include <filesystem>
#include <memory>
#include <vector>

View File

@ -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

View File

@ -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))
{