Some pose performance improvements by aldeck and myself:

1) We don't need to call FindPose() on every pose as we're freshly adding it,
and a duplicate should never happen in this circumstance (the FindPose() is still there if
Tracker is compiled in debug mode however.
2) Adjust the FSClipboard calls such that the locking is optional. This allows us to lock
once per CreatePoses group rather than once per pose.

Together these changes make for a significant performance improvement when it comes to
populating a large folder.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29198 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2009-02-14 19:54:47 +00:00
parent 3e01561729
commit 95da064570
5 changed files with 58 additions and 50 deletions

View File

@ -504,11 +504,13 @@ FSClipboardPaste(Model *model, uint32 linksMode)
*/ */
uint32 uint32
FSClipboardFindNodeMode(Model *model, bool updateRefIfNeeded) FSClipboardFindNodeMode(Model *model, bool autoLock, bool updateRefIfNeeded)
{ {
int32 moveMode = 0; int32 moveMode = 0;
if (autoLock) {
if (be_clipboard->Lock()) { if (!be_clipboard->Lock())
return 0;
}
bool remove = false; bool remove = false;
bool change = false; bool change = false;
@ -546,11 +548,11 @@ FSClipboardFindNodeMode(Model *model, bool updateRefIfNeeded)
if (change) if (change)
be_clipboard->Commit(); be_clipboard->Commit();
if (autoLock)
be_clipboard->Unlock(); be_clipboard->Unlock();
if (remove) if (remove)
FSClipboardRemove(model); FSClipboardRemove(model);
}
return (uint32)moveMode; return (uint32)moveMode;
} }

View File

@ -90,6 +90,6 @@ uint32 FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 mov
uint32 FSClipboardRemovePoses(const node_ref *directory, PoseList *list); uint32 FSClipboardRemovePoses(const node_ref *directory, PoseList *list);
bool FSClipboardPaste(Model *model, uint32 linksMode = 0); bool FSClipboardPaste(Model *model, uint32 linksMode = 0);
void FSClipboardRemove(Model *model); void FSClipboardRemove(Model *model);
uint32 FSClipboardFindNodeMode(Model *model, bool updateRefIfNeeded); uint32 FSClipboardFindNodeMode(Model *model, bool autoLock, bool updateRefIfNeeded);
#endif /* FS_CLIPBOARD_H */ #endif /* FS_CLIPBOARD_H */

View File

@ -66,9 +66,10 @@ CalcFreeSpace(BVolume *volume)
// everything else, like the attributes, etc. is retrieved directly from the // everything else, like the attributes, etc. is retrieved directly from the
// symlink itself // symlink itself
BPose::BPose(Model *model, BPoseView *view, bool selected) BPose::BPose(Model *model, BPoseView *view, uint32 clipboardMode, bool selected)
: fModel(model), : fModel(model),
fWidgetList(4, true), fWidgetList(4, true),
fClipboardMode(clipboardMode),
fPercent(-1), fPercent(-1),
fIsSelected(selected), fIsSelected(selected),
fDelayedEdit(true), fDelayedEdit(true),
@ -108,11 +109,6 @@ BPose::BPose(Model *model, BPoseView *view, bool selected)
} else } else
delete volume; delete volume;
} }
if ((fClipboardMode = FSClipboardFindNodeMode(model,true)) != 0
&& !view->HasPosesInClipboard()) {
view->SetHasPosesInClipboard(true);
}
} }

View File

@ -54,7 +54,7 @@ enum {
class BPose { class BPose {
public: public:
BPose(Model *adopt, BPoseView *, bool selected = false); BPose(Model *adopt, BPoseView *, uint32 clipboardMode, bool selected = false);
virtual ~BPose(); virtual ~BPose();
BTextWidget *AddWidget(BPoseView *, BColumn *); BTextWidget *AddWidget(BPoseView *, BColumn *);

View File

@ -1615,12 +1615,15 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
else else
viewBounds = Bounds(); viewBounds = Bounds();
be_clipboard->Lock();
int32 poseIndex = 0; int32 poseIndex = 0;
uint32 clipboardMode = 0;
float listViewScrollBy = 0; float listViewScrollBy = 0;
for (int32 modelIndex = 0; modelIndex < count; modelIndex++) { for (int32 modelIndex = 0; modelIndex < count; modelIndex++) {
Model *model = models[modelIndex]; Model *model = models[modelIndex];
ASSERT(!FindPose(model));
if (FindPose(model) || FindZombie(model->NodeRef())) { if (FindZombie(model->NodeRef())) {
// we already have this pose, don't add it // we already have this pose, don't add it
watch_node(model->NodeRef(), B_STOP_WATCHING, this); watch_node(model->NodeRef(), B_STOP_WATCHING, this);
delete model; delete model;
@ -1629,12 +1632,17 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
continue; continue;
} }
if ((clipboardMode = FSClipboardFindNodeMode(model,false,true)) != 0
&& !HasPosesInClipboard()) {
SetHasPosesInClipboard(true);
}
model->OpenNode(); model->OpenNode();
ASSERT(model->IsNodeOpen()); ASSERT(model->IsNodeOpen());
PoseInfo *poseInfo = &poseInfoArray[modelIndex]; PoseInfo *poseInfo = &poseInfoArray[modelIndex];
// pose adopts model and deletes it when done // pose adopts model and deletes it when done
BPose *pose = new BPose(model, this); BPose *pose = new BPose(model, this, clipboardMode);
if (resultingPoses) if (resultingPoses)
resultingPoses[modelIndex] = pose; resultingPoses[modelIndex] = pose;
@ -1760,6 +1768,8 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
model->CloseNode(); model->CloseNode();
} }
be_clipboard->Unlock();
FinishPendingScroll(listViewScrollBy, viewBounds); FinishPendingScroll(listViewScrollBy, viewBounds);
if (lastPoseIndexPtr) if (lastPoseIndexPtr)