Rework this again due to flaws in the previous optimization - due to its use for things like sorting the visible pose list, it would rely on whatever pose column was being used for sorting, and as such would generate false positives when the view was being ordered by certain attributes. We now use an std::hash_set to track all the nodes that have been added to the current view and use that for a duplicate check instead. Also slightly boost the max number of models per chunk that we read.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29414 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2009-03-06 13:42:33 +00:00
parent 7d1d70339a
commit 38f4625170
2 changed files with 21 additions and 7 deletions

View File

@ -99,7 +99,7 @@ const float kCountViewWidth = 62;
const uint32 kAddNewPoses = 'Tanp';
const uint32 kAddPosesCompleted = 'Tapc';
const int32 kMaxAddPosesChunk = 10;
const int32 kMaxAddPosesChunk = 50;
namespace BPrivate {
extern bool delete_point(void *);
@ -1632,20 +1632,18 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
for (int32 modelIndex = 0; modelIndex < count; modelIndex++) {
Model *model = models[modelIndex];
model->OpenNode();
ASSERT(model->IsNodeOpen());
PoseInfo *poseInfo = &poseInfoArray[modelIndex];
// pose adopts model and deletes it when done
BPose *pose = new BPose(model, this, clipboardMode);
if (BSearch(fPoseList, pose, this, PoseCompareAddWidget, false) != NULL
if (fInsertedNodes.find(*(model->NodeRef())) != fInsertedNodes.end()
|| FindZombie(model->NodeRef())) {
watch_node(model->NodeRef(), B_STOP_WATCHING, this);
delete pose;
delete model;
if (resultingPoses)
resultingPoses[modelIndex] = NULL;
continue;
} else {
fInsertedNodes.insert(*(model->NodeRef()));
}
if ((clipboardMode = FSClipboardFindNodeMode(model,false,true)) != 0
@ -1653,6 +1651,11 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
SetHasPosesInClipboard(true);
}
model->OpenNode();
ASSERT(model->IsNodeOpen());
PoseInfo *poseInfo = &poseInfoArray[modelIndex];
BPose *pose = new BPose(model, this, clipboardMode);
if (resultingPoses)
resultingPoses[modelIndex] = pose;

View File

@ -57,11 +57,21 @@ All rights reserved.
#include <String.h>
#include <ScrollBar.h>
#include <View.h>
#include <hash_set>
#include <set>
class BRefFilter;
class BList;
__STL_TEMPLATE_NULL struct std::hash<node_ref>
{
size_t operator()(node_ref ref) const {
return ref.node;
}
};
namespace BPrivate {
class BCountView;
@ -598,6 +608,7 @@ class BPoseView : public BView {
PoseList *fPoseList;
PoseList *fVSPoseList;
PoseList *fSelectionList;
std::hash_set<node_ref, std::hash<node_ref> > fInsertedNodes;
BObjectList<BString> fMimeTypesInSelectionCache;
// used for mime string based icon highliting during a drag
BObjectList<Model> *fZombieList;