From 8adb3eb6eb2d8c76d4b13be6fd126c4f22dc387a Mon Sep 17 00:00:00 2001 From: Andres Pagliano Date: Fri, 30 Nov 2012 10:38:27 -0300 Subject: [PATCH] Refactoring in CCSet --- cocos2dx/cocoa/CCSet.cpp | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/cocos2dx/cocoa/CCSet.cpp b/cocos2dx/cocoa/CCSet.cpp index 0078cfb5d9..8ab306af56 100644 --- a/cocos2dx/cocoa/CCSet.cpp +++ b/cocos2dx/cocoa/CCSet.cpp @@ -52,18 +52,7 @@ CCSet::CCSet(const CCSet &rSetObject) CCSet::~CCSet(void) { - // call release() of elements - CCSetIterator iter; - for (iter = m_pSet->begin(); iter != m_pSet->end(); ++iter) - { - if (! (*iter)) - { - break; - } - - (*iter)->release(); - } - + removeAllObjects(); CC_SAFE_DELETE(m_pSet); } @@ -98,20 +87,16 @@ void CCSet::removeObject(CCObject *pObject) void CCSet::removeAllObjects() { - if (!m_pSet || m_pSet->empty()) - { - return; - } + CCSetIterator it; + for (it = m_pSet->begin(); it != m_pSet->end(); ++it) + { + if (! (*it)) + { + break; + } - CCSetIterator it; - - for( it = m_pSet->begin(); it != m_pSet->end(); ++it) - { - if(*it) - { - removeObject(*it); - } - } + (*it)->release(); + } } bool CCSet::containsObject(CCObject *pObject)