If the wait object group only contains a single object, don't create a tree node

for the group, but just for the object.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30452 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-04-26 22:53:57 +00:00
parent 84b7a2d098
commit 1d124d4db1
1 changed files with 14 additions and 3 deletions

View File

@ -147,8 +147,8 @@ private:
friend struct GroupNode;
struct RootNode : Node {
ThreadModel* threadModel;
BObjectList<GroupNode> groupNodes;
ThreadModel* threadModel;
BObjectList<Node> groupNodes;
RootNode(ThreadModel* model)
:
@ -159,7 +159,7 @@ private:
for (int32 i = 0; i < count; i++) {
ThreadModel::WaitObjectGroup* group
= threadModel->WaitObjectGroupAt(i);
if (!groupNodes.AddItem(new GroupNode(group)))
if (!groupNodes.AddItem(_CreateGroupNode(group)))
throw std::bad_alloc();
}
}
@ -178,6 +178,17 @@ private:
{
return false;
}
private:
static Node* _CreateGroupNode(ThreadModel::WaitObjectGroup* group)
{
// If the group has only one object, just create an object node.
if (group->CountWaitObjects() == 1)
return new ObjectNode(group->WaitObjectAt(0));
return new GroupNode(group);
}
};
private: