From 5751e3818035b82b14ac5a426ba0f4f80417f184 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 27 Jan 2017 18:25:25 +0100 Subject: [PATCH] gsdx: use range loop instead of for_each --- plugins/GSdx/GSDevice.cpp | 4 ++-- plugins/GSdx/GSDevice9.cpp | 8 ++++---- plugins/GSdx/GSFunctionMap.h | 2 +- plugins/GSdx/GSLocalMemory.cpp | 6 +++--- plugins/GSdx/GSTextureCache.cpp | 6 +++--- plugins/GSdx/GSTextureCacheSW.cpp | 2 +- plugins/GSdx/stdafx.h | 7 ------- 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/plugins/GSdx/GSDevice.cpp b/plugins/GSdx/GSDevice.cpp index c98bb7a154..74ea923384 100644 --- a/plugins/GSdx/GSDevice.cpp +++ b/plugins/GSdx/GSDevice.cpp @@ -45,7 +45,7 @@ GSDevice::GSDevice() GSDevice::~GSDevice() { - for_each(m_pool.begin(), m_pool.end(), delete_object()); + for(auto &t : m_pool) delete t; delete m_backbuffer; delete m_merge; @@ -66,7 +66,7 @@ bool GSDevice::Create(GSWnd* wnd) bool GSDevice::Reset(int w, int h) { - for_each(m_pool.begin(), m_pool.end(), delete_object()); + for(auto &t : m_pool) delete t; m_pool.clear(); diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 04a15f706e..088ce45d6b 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -42,10 +42,10 @@ GSDevice9::GSDevice9() GSDevice9::~GSDevice9() { - for_each(m_om_bs.begin(), m_om_bs.end(), delete_second()); - for_each(m_om_dss.begin(), m_om_dss.end(), delete_second()); - for_each(m_ps_ss.begin(), m_ps_ss.end(), delete_second()); - for_each(m_mskfix.begin(), m_mskfix.end(), delete_second()); + for(auto &i : m_om_bs) delete i.second; + for(auto &i : m_om_dss) delete i.second; + for(auto &i : m_ps_ss) delete i.second; + for(auto &i : m_mskfix) delete i.second; if(m_state.vs_cb) _aligned_free(m_state.vs_cb); if(m_state.ps_cb) _aligned_free(m_state.ps_cb); diff --git a/plugins/GSdx/GSFunctionMap.h b/plugins/GSdx/GSFunctionMap.h index 3100249693..2e4204293c 100644 --- a/plugins/GSdx/GSFunctionMap.h +++ b/plugins/GSdx/GSFunctionMap.h @@ -53,7 +53,7 @@ public: virtual ~GSFunctionMap() { - for_each(m_map_active.begin(), m_map_active.end(), delete_second()); + for(auto &i : m_map_active) delete i.second; } VALUE operator [] (KEY key) diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 5b807350d3..aa2a0c973d 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -477,9 +477,9 @@ GSLocalMemory::~GSLocalMemory() else vmfree(m_vm8, m_vmsize * 4); - for_each(m_omap.begin(), m_omap.end(), aligned_free_second()); - for_each(m_pomap.begin(), m_pomap.end(), aligned_free_second()); - for_each(m_po4map.begin(), m_po4map.end(), aligned_free_second()); + for(auto &i : m_omap) _aligned_free(i.second); + for(auto &i : m_pomap) _aligned_free(i.second); + for(auto &i : m_po4map) _aligned_free(i.second); for(hash_map*>::iterator i = m_p2tmap.begin(); i != m_p2tmap.end(); ++i) { diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index ae7086c06c..1c6405e376 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -72,7 +72,7 @@ void GSTextureCache::RemovePartial() for (int type = 0; type < 2; type++) { - for_each(m_dst[type].begin(), m_dst[type].end(), delete_object()); + for (auto &t : m_dst[type]) delete t; m_dst[type].clear(); } @@ -84,7 +84,7 @@ void GSTextureCache::RemoveAll() for(int type = 0; type < 2; type++) { - for_each(m_dst[type].begin(), m_dst[type].end(), delete_object()); + for (auto &t : m_dst[type]) delete t; m_dst[type].clear(); } @@ -2021,7 +2021,7 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSOffset* void GSTextureCache::SourceMap::RemoveAll() { - for_each(m_surfaces.begin(), m_surfaces.end(), delete_object()); + for (auto &t : m_surfaces) delete t; m_surfaces.clear(); diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index cdb28faf56..59118fa4d3 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -121,7 +121,7 @@ void GSTextureCacheSW::InvalidatePages(const uint32* pages, uint32 psm) void GSTextureCacheSW::RemoveAll() { - for_each(m_textures.begin(), m_textures.end(), delete_object()); + for(auto &i : m_textures) delete i; m_textures.clear(); diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index ef0865035d..c467994eaf 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -430,13 +430,6 @@ using namespace stdext; extern string format(const char* fmt, ...); -struct delete_object {template void operator()(T& p) {delete p;}}; -struct delete_first {template void operator()(T& p) {delete p.first;}}; -struct delete_second {template void operator()(T& p) {delete p.second;}}; -struct aligned_free_object {template void operator()(T& p) {_aligned_free(p);}}; -struct aligned_free_first {template void operator()(T& p) {_aligned_free(p.first);}}; -struct aligned_free_second {template void operator()(T& p) {_aligned_free(p.second);}}; - extern void* vmalloc(size_t size, bool code); extern void vmfree(void* ptr, size_t size);