Projects > cpp > Issues > Refactor #1198

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Optimize CCTextureCache::removeUnusedTextures()

Refactor #1198 [Closed]
zhangxm 2012-04-28 02:05 . Updated over 2 years ago

Current implementation removes element when looping.
The efficiency is not so good.

The codes below, offered by inter engineer zhuoshi sun, will improve performance.

 //< modified by sunzhuoshi
     if (m_pTextures->begin())
      {
         CCTexture2D *texture = NULL;
         std::string key;
         std::list keysToRemove;
          while (texture = m_pTextures->next(&key))
          {
             if (texture->retainCount() == 1)
              {
                 keysToRemove.push_back(key);
             }
         };
         m_pTextures->end();
         for (std::list::iterator it=keysToRemove.begin(); it!=keysToRemove.end(); ++it)          {
             CCLOG("cocos2d: CCTextureCache: removing unused texture: %s", (*it).c_str());             
             m_pTextures->removeObjectForKey(*it);
         }
     }     //>

The codes should be integrated into gles20 branch.

zhangxm 2012-04-28 02:10
  • Subject changed from Optimize CCRenderTexture::removeUnusedTextures() to Optimize CCTextureCache::removeUnusedTextures()
zhangxm 2012-04-28 02:35
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset commit:564a366218133946b625a26c953470da391e7c25.

zhangxm 2012-04-28 02:35

Applied in changeset commit:a51143239d70998bd84646a8acd1e7475adfb3c5.

walzer 2012-05-25 07:57
  • Project changed from cocos2d-x to cpp
  • Category deleted (5)
  • Target version deleted (23)
zhangxm 2012-05-25 09:31

Applied in changeset commit:564a366218133946b625a26c953470da391e7c25.

zhangxm 2012-05-25 09:31

Applied in changeset commit:a51143239d70998bd84646a8acd1e7475adfb3c5.

walzer 2012-05-25 09:49
  • Target version set to cocos2d-2.0-rc0a-x-2.0
zhangxm 2012-05-28 05:50
  • Category set to 12
  • Status changed from Resolved to Closed

Atom PDF

Status:Closed
Start date:2012-04-28
Priority:Normal
Due date:
Assignee:zhangxm
% Done:

100%

Category:all
Target version:cocos2d-2.0-rc0a-x-2.0

Copyright © 2010 - 2014 Cocos2d-x.org Support Email: support@cocos.org