From 29c4f83fd8b738f05492aa7bd3011d3ed1d22f27 Mon Sep 17 00:00:00 2001 From: G17hao <670788361@qq.com> Date: Tue, 20 Jan 2015 19:28:30 +0800 Subject: [PATCH] Update CCGroupCommand.cpp add a vector container for save unused id. traversal unordered_map is too slow, use vector to replace it --- cocos/renderer/CCGroupCommand.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/renderer/CCGroupCommand.cpp b/cocos/renderer/CCGroupCommand.cpp index 576dab111e..24874f4351 100644 --- a/cocos/renderer/CCGroupCommand.cpp +++ b/cocos/renderer/CCGroupCommand.cpp @@ -49,13 +49,12 @@ bool GroupCommandManager::init() int GroupCommandManager::getGroupID() { //Reuse old id - for(auto it = _groupMapping.begin(); it != _groupMapping.end(); ++it) + if (!_unusedIDs.empty()) { - if(!it->second) - { - _groupMapping[it->first] = true; - return it->first; - } + int groupID = *_unusedIDs.rbegin(); + _unusedIDs.pop_back(); + _groupMapping[groupID] = true; + return groupID; } //Create new ID @@ -69,6 +68,7 @@ int GroupCommandManager::getGroupID() void GroupCommandManager::releaseGroupID(int groupID) { _groupMapping[groupID] = false; + _unusedIDs.push_back(groupID); } GroupCommand::GroupCommand()