Skip to content

Commit ad8c0b0

Browse files
committed
Common/object_destroyer.h: use range-based for
Change LPCSTR, LPSTR -> pcstr pstr
1 parent dbcfab6 commit ad8c0b0

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

src/Common/object_destroyer.h

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
struct CDestroyer
1313
{
14-
static void delete_data(LPCSTR /*data*/) {}
15-
static void delete_data(LPSTR data) { xr_free(data); }
14+
static void delete_data(pcstr /*data*/) {}
15+
static void delete_data(pstr data) { xr_free(data); }
1616
template <typename T1, typename T2>
1717
static void delete_data(std::pair<T1, T2>& data)
1818
{
@@ -23,44 +23,37 @@ struct CDestroyer
2323
template <typename T, int size>
2424
static void delete_data(svector<T, size>& data)
2525
{
26-
svector<T, size>::iterator I = data.begin();
27-
svector<T, size>::iterator E = data.end();
28-
for (; I != E; ++I)
29-
delete_data(*I);
26+
for (auto& it : data)
27+
delete_data(it);
3028
data.clear();
3129
}
3230

3331
template <typename T, int n>
3432
static void delete_data(T (&array)[n])
3533
{
36-
T* I = array;
37-
T* E = array + n;
38-
for (; I != E; ++I)
39-
delete_data(*I);
34+
for (auto& it : array)
35+
delete_data(it);
4036
}
4137

4238
template <typename T1, typename T2>
4339
static void delete_data(std::queue<T1, T2>& data)
4440
{
45-
std::queue<T1, T2> temp = data;
46-
for (; !temp.empty(); temp.pop())
47-
delete_data(temp.front());
41+
for (auto& it : data)
42+
delete_data(it);
4843
}
4944

5045
template <template <typename TX1, typename TX2> class T1, typename T2, typename T3>
5146
static void delete_data(T1<T2, T3>& data, bool)
5247
{
53-
T1<T2, T3> temp = data;
54-
for (; !temp.empty(); temp.pop())
55-
delete_data(temp.top());
48+
for (auto& it : data)
49+
delete_data(it);
5650
}
5751

5852
template <template <typename TX1, typename TX2, typename TX3> class T1, typename T2, typename T3, typename T4>
5953
static void delete_data(T1<T2, T3, T4>& data, bool)
6054
{
61-
T1<T2, T3, T4> temp = data;
62-
for (; !temp.empty(); temp.pop())
63-
delete_data(temp.top());
55+
for (auto& it : data)
56+
delete_data(it);
6457
}
6558

6659
template <typename T1, typename T2>
@@ -113,10 +106,8 @@ struct CDestroyer
113106
template <typename T>
114107
static void delete_data(T& data)
115108
{
116-
T::iterator I = data.begin();
117-
T::iterator E = data.end();
118-
for (; I != E; ++I)
119-
CDestroyer::delete_data(*I);
109+
for (auto& it : data)
110+
CDestroyer::delete_data(it);
120111
data.clear();
121112
}
122113
};

0 commit comments

Comments
 (0)