mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-15 09:17:57 -05:00
refactor: use std ranges functions where applicable
This commit is contained in:
@ -56,12 +56,11 @@ class IPak::Impl : public ObjContainerReferenceable
|
||||
m_index_entries.push_back(indexEntry);
|
||||
}
|
||||
|
||||
std::sort(m_index_entries.begin(),
|
||||
m_index_entries.end(),
|
||||
[](const IPakIndexEntry& entry1, const IPakIndexEntry& entry2)
|
||||
{
|
||||
return entry1.key.combinedKey < entry2.key.combinedKey;
|
||||
});
|
||||
std::ranges::sort(m_index_entries,
|
||||
[](const IPakIndexEntry& entry1, const IPakIndexEntry& entry2)
|
||||
{
|
||||
return entry1.key.combinedKey < entry2.key.combinedKey;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -71,12 +71,11 @@ public:
|
||||
m_stream_mutex.lock();
|
||||
|
||||
ChunkBuffer* reservedChunkBuffer;
|
||||
const auto freeChunkBuffer = std::find_if(m_chunk_buffers.begin(),
|
||||
m_chunk_buffers.end(),
|
||||
[](ChunkBuffer* chunkBuffer)
|
||||
{
|
||||
return chunkBuffer->m_using_stream == nullptr;
|
||||
});
|
||||
const auto freeChunkBuffer = std::ranges::find_if(m_chunk_buffers,
|
||||
[](ChunkBuffer* chunkBuffer)
|
||||
{
|
||||
return chunkBuffer->m_using_stream == nullptr;
|
||||
});
|
||||
|
||||
if (freeChunkBuffer == m_chunk_buffers.end())
|
||||
{
|
||||
@ -111,12 +110,11 @@ public:
|
||||
{
|
||||
m_stream_mutex.lock();
|
||||
|
||||
const auto openStreamEntry = std::find_if(m_open_streams.begin(),
|
||||
m_open_streams.end(),
|
||||
[stream](const ManagedStream& managedStream)
|
||||
{
|
||||
return managedStream.m_stream == stream;
|
||||
});
|
||||
const auto openStreamEntry = std::ranges::find_if(m_open_streams,
|
||||
[stream](const ManagedStream& managedStream)
|
||||
{
|
||||
return managedStream.m_stream == stream;
|
||||
});
|
||||
|
||||
if (openStreamEntry != m_open_streams.end())
|
||||
{
|
||||
@ -127,7 +125,7 @@ public:
|
||||
// Only keep previously allocated chunk buffer if we did not get over the limit of idle chunk buffers
|
||||
if (m_chunk_buffers.size() > CHUNK_BUFFER_COUNT_IDLE_LIMIT)
|
||||
{
|
||||
const auto chunkBufferEntry = std::find(m_chunk_buffers.begin(), m_chunk_buffers.end(), chunkBuffer);
|
||||
const auto chunkBufferEntry = std::ranges::find(m_chunk_buffers, chunkBuffer);
|
||||
|
||||
if (chunkBufferEntry != m_chunk_buffers.end())
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ public:
|
||||
}
|
||||
|
||||
auto iwdFilename = fileName;
|
||||
std::replace(iwdFilename.begin(), iwdFilename.end(), '\\', '/');
|
||||
std::ranges::replace(iwdFilename, '\\', '/');
|
||||
|
||||
const auto iwdEntry = m_entry_map.find(iwdFilename);
|
||||
|
||||
|
@ -46,12 +46,11 @@ public:
|
||||
|
||||
void AddSound(const std::string& soundFilePath, unsigned int soundId, bool looping, bool streamed) override
|
||||
{
|
||||
auto itr = std::find_if(this->m_sounds.begin(),
|
||||
this->m_sounds.end(),
|
||||
[soundId](SoundBankEntryInfo& entry)
|
||||
{
|
||||
return entry.m_sound_id == soundId;
|
||||
});
|
||||
auto itr = std::ranges::find_if(this->m_sounds,
|
||||
[soundId](SoundBankEntryInfo& entry)
|
||||
{
|
||||
return entry.m_sound_id == soundId;
|
||||
});
|
||||
|
||||
if (itr == this->m_sounds.end())
|
||||
{
|
||||
|
Reference in New Issue
Block a user