Andrew Smith
2008-07-23 08:30:18 UTC
Hi all,
Using BCB 6 - I put a TTreeView with a single top node onto a form and
populated it like this:
tree->Items->BeginUpdate();
for (int i=0; i < 1000; i++)
{
tree->Items->AddChild(tree->TopItem, IntToStr(i));
}
tree->Items->EndUpdate();
That takes no time at all. I have a button on the form which does this when
clicked:
for (int i=0; i < tree->TopItem->Count; i++)
{
TreeNode *node = tree->TopItem->Items[i];
}
For some reason, this takes about 10 seconds on my 2GHz Core 2 Duo. Am I
missing something here? Shouldn't this be pretty much instantaneous?
Interestingly, it only seems slow to loop through a node's children. If I
add the 1000 nodes to the root of the tree and loop through those, it's done
instantly.
Anyone got any suggestions?
Cheers,
Andrew
Using BCB 6 - I put a TTreeView with a single top node onto a form and
populated it like this:
tree->Items->BeginUpdate();
for (int i=0; i < 1000; i++)
{
tree->Items->AddChild(tree->TopItem, IntToStr(i));
}
tree->Items->EndUpdate();
That takes no time at all. I have a button on the form which does this when
clicked:
for (int i=0; i < tree->TopItem->Count; i++)
{
TreeNode *node = tree->TopItem->Items[i];
}
For some reason, this takes about 10 seconds on my 2GHz Core 2 Duo. Am I
missing something here? Shouldn't this be pretty much instantaneous?
Interestingly, it only seems slow to loop through a node's children. If I
add the 1000 nodes to the root of the tree and loop through those, it's done
instantly.
Anyone got any suggestions?
Cheers,
Andrew