From 9e1508a585d30979c9cc9b383e664d9e0bcdf054 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Sat, 6 Jan 2018 22:43:31 +0500 Subject: [PATCH] xrCore/xrPool.h: a bit of refactor and reformatting Used range-based for --- src/xrCore/xrPool.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/xrCore/xrPool.h b/src/xrCore/xrPool.h index d600f3034ab..1f556c2167d 100644 --- a/src/xrCore/xrPool.h +++ b/src/xrCore/xrPool.h @@ -1,23 +1,17 @@ #pragma once -#ifndef xrPoolH -#define xrPoolH -#include "_types.h" #include "xrDebug_macros.h" -//#include "_stl_extensions.h" template class poolSS { -private: T* list; xr_vector blocks; -private: T** access(T* P) { return (T**)LPVOID(P); } void block_create() { // Allocate - VERIFY(0 == list); + VERIFY(nullptr == list); list = xr_alloc(granularity); blocks.push_back(list); @@ -27,15 +21,15 @@ class poolSS T* E = list + it; *access(E) = E + 1; } - *access(list + granularity - 1) = NULL; + *access(list + granularity - 1) = nullptr; } public: - poolSS() { list = 0; } + poolSS() : list(nullptr) {} ~poolSS() { - for (u32 b = 0; b < blocks.size(); b++) - xr_free(blocks[b]); + for (auto& block : blocks) + xr_free(block); } T* create() { @@ -51,14 +45,13 @@ class poolSS P->~T(); *access(P) = list; list = P; - P = NULL; + P = nullptr; } void clear() { - list = 0; - for (u32 b = 0; b < blocks.size(); b++) - xr_free(blocks[b]); + list = nullptr; + for (auto& block : blocks) + xr_free(block); blocks.clear(); } }; -#endif