Codechange: Use range-based for-loop in Auto[Free|Delete]SmallVector

This commit is contained in:
Henry Wilson 2019-03-13 20:55:31 +00:00 committed by PeterN
parent cc62f4163f
commit 03ca3190c9
2 changed files with 5 additions and 5 deletions

View File

@ -91,8 +91,8 @@ public:
*/ */
inline void Clear() inline void Clear()
{ {
for (uint i = 0; i < std::vector<T>::size(); i++) { for (T p : *this) {
free(std::vector<T>::operator[](i)); free(p);
} }
std::vector<T>::clear(); std::vector<T>::clear();
@ -121,8 +121,8 @@ public:
*/ */
inline void Clear() inline void Clear()
{ {
for (uint i = 0; i < std::vector<T>::size(); i++) { for (T p : *this) {
delete std::vector<T>::operator[](i); delete p;
} }
std::vector<T>::clear(); std::vector<T>::clear();

View File

@ -32,7 +32,7 @@ namespace SQConvert {
struct SQAutoFreePointers : std::vector<void *> { struct SQAutoFreePointers : std::vector<void *> {
~SQAutoFreePointers() ~SQAutoFreePointers()
{ {
for (uint i = 0; i < std::vector<void *>::size(); i++) free(std::vector<void *>::operator[](i)); for (void * p : *this) free(p);
} }
}; };