Skip to content

Commit 9e1508a

Browse files
committed
xrCore/xrPool.h: a bit of refactor and reformatting
Used range-based for
1 parent f25a1be commit 9e1508a

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/xrCore/xrPool.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
#pragma once
2-
#ifndef xrPoolH
3-
#define xrPoolH
4-
#include "_types.h"
52
#include "xrDebug_macros.h"
6-
//#include "_stl_extensions.h"
73

84
template <class T, int granularity>
95
class poolSS
106
{
11-
private:
127
T* list;
138
xr_vector<T*> blocks;
149

15-
private:
1610
T** access(T* P) { return (T**)LPVOID(P); }
1711
void block_create()
1812
{
1913
// Allocate
20-
VERIFY(0 == list);
14+
VERIFY(nullptr == list);
2115
list = xr_alloc<T>(granularity);
2216
blocks.push_back(list);
2317

@@ -27,15 +21,15 @@ class poolSS
2721
T* E = list + it;
2822
*access(E) = E + 1;
2923
}
30-
*access(list + granularity - 1) = NULL;
24+
*access(list + granularity - 1) = nullptr;
3125
}
3226

3327
public:
34-
poolSS() { list = 0; }
28+
poolSS() : list(nullptr) {}
3529
~poolSS()
3630
{
37-
for (u32 b = 0; b < blocks.size(); b++)
38-
xr_free(blocks[b]);
31+
for (auto& block : blocks)
32+
xr_free(block);
3933
}
4034
T* create()
4135
{
@@ -51,14 +45,13 @@ class poolSS
5145
P->~T();
5246
*access(P) = list;
5347
list = P;
54-
P = NULL;
48+
P = nullptr;
5549
}
5650
void clear()
5751
{
58-
list = 0;
59-
for (u32 b = 0; b < blocks.size(); b++)
60-
xr_free(blocks[b]);
52+
list = nullptr;
53+
for (auto& block : blocks)
54+
xr_free(block);
6155
blocks.clear();
6256
}
6357
};
64-
#endif

0 commit comments

Comments
 (0)