From b7cf823ee77858b3d105f4953aab55badb3dc362 Mon Sep 17 00:00:00 2001 From: Silent Date: Sat, 23 Dec 2017 14:14:21 +0100 Subject: [PATCH] Move initializer list instead of copying Use make_checked_array_iterator properly where applicable --- SilentPatch/MemoryMgr.h | 8 ++++---- SilentPatchSA/FLACDecoderSA.cpp | 4 ++-- SilentPatchSA/ModelInfoSA.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/SilentPatch/MemoryMgr.h b/SilentPatch/MemoryMgr.h index 64ffd87..0b1624e 100644 --- a/SilentPatch/MemoryMgr.h +++ b/SilentPatch/MemoryMgr.h @@ -432,7 +432,7 @@ namespace Memory inline void Patch(AT address, std::initializer_list list ) { uint8_t* const addr = (uint8_t*)address; - std::copy( list.begin(), list.end(), stdext::checked_array_iterator(addr, list.size()) ); + std::copy( list.begin(), list.end(), stdext::make_checked_array_iterator(addr, list.size()) ); } #endif @@ -531,7 +531,7 @@ namespace Memory #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { - return Memory::MemEquals(DynBaseAddress(address), val); + return Memory::MemEquals(DynBaseAddress(address), std::move(val)); } #endif }; @@ -596,7 +596,7 @@ namespace Memory #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { - return Memory::MemEquals(address, val); + return Memory::MemEquals(address, std::move(val)); } #endif @@ -643,7 +643,7 @@ namespace Memory #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { - return Memory::MemEquals(DynBaseAddress(address), val); + return Memory::MemEquals(DynBaseAddress(address), std::move(val)); } #endif }; diff --git a/SilentPatchSA/FLACDecoderSA.cpp b/SilentPatchSA/FLACDecoderSA.cpp index 999e31c..4bd1ce0 100644 --- a/SilentPatchSA/FLACDecoderSA.cpp +++ b/SilentPatchSA/FLACDecoderSA.cpp @@ -50,10 +50,10 @@ FLAC__StreamDecoderWriteStatus CAEFLACDecoder::write_cb(const FLAC__StreamDecode pClientData->m_maxBlockSize = pClientData->m_curBlockSize; } - std::copy_n( buffer[0], pClientData->m_curBlockSize, stdext::checked_array_iterator(pClientData->m_buffer, pClientData->m_curBlockSize) ); + std::copy_n( buffer[0], pClientData->m_curBlockSize, stdext::make_checked_array_iterator(pClientData->m_buffer, pClientData->m_curBlockSize) ); if ( processedChannels > 1 ) { - std::copy_n( buffer[1], pClientData->m_curBlockSize, stdext::checked_array_iterator(pClientData->m_buffer+pClientData->m_curBlockSize, pClientData->m_curBlockSize) ); + std::copy_n( buffer[1], pClientData->m_curBlockSize, stdext::make_checked_array_iterator(pClientData->m_buffer+pClientData->m_curBlockSize, pClientData->m_curBlockSize) ); } return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; diff --git a/SilentPatchSA/ModelInfoSA.cpp b/SilentPatchSA/ModelInfoSA.cpp index e329c34..16beb41 100644 --- a/SilentPatchSA/ModelInfoSA.cpp +++ b/SilentPatchSA/ModelInfoSA.cpp @@ -72,7 +72,7 @@ void CVehicleModelInfo::FindEditableMaterialList() if ( m_numDirtMaterials > IN_PLACE_BUFFER_DIRT_SIZE ) { m_dirtMaterials = new RpMaterial* [m_numDirtMaterials]; - std::copy( editableMaterials.begin(), editableMaterials.end(), stdext::checked_array_iterator(m_dirtMaterials, m_numDirtMaterials) ); + std::copy( editableMaterials.begin(), editableMaterials.end(), stdext::make_checked_array_iterator(m_dirtMaterials, m_numDirtMaterials) ); } else { @@ -131,13 +131,13 @@ void CCustomCarPlateMgr::PollPlates( RpClump* clump, PlateMaterialsData* materia if ( materials->m_numPlates > 0 ) { materials->m_plates = new RpMaterial* [materials->m_numPlates]; - std::copy( carplates.begin(), carplates.end(), stdext::checked_array_iterator(materials->m_plates, materials->m_numPlates) ); + std::copy( carplates.begin(), carplates.end(), stdext::make_checked_array_iterator(materials->m_plates, materials->m_numPlates) ); } if ( materials->m_numPlatebacks > 0 ) { materials->m_platebacks = new RpMaterial* [materials->m_numPlatebacks]; - std::copy( carpbacks.begin(), carpbacks.end(), stdext::checked_array_iterator(materials->m_platebacks, materials->m_numPlatebacks) ); + std::copy( carpbacks.begin(), carpbacks.end(), stdext::make_checked_array_iterator(materials->m_platebacks, materials->m_numPlatebacks) ); } }