Minor optimization: since our list items cache their position information,

take advantage of this fact to make use of binary search in 
IndexOf(BListItem *), rather than using BList's linear search. 
Also use this mechanism to speed up HasItem(BListItem *).



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28694 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2008-11-19 04:41:51 +00:00
parent 633645bca9
commit 128cb2f6f3
+8 -2
View File
@@ -733,7 +733,13 @@ BListView::ItemAt(int32 index) const
int32
BListView::IndexOf(BListItem *item) const
{
return fList.IndexOf(item);
if (item != NULL) {
BPoint point(0.0, item->Top());
int32 index = IndexOf(point);
if (index >= 0 && fList.ItemAt(index) == item)
return index;
}
return -1;
}
// IndexOf
@@ -779,7 +785,7 @@ BListView::LastItem() const
bool
BListView::HasItem(BListItem *item) const
{
return fList.HasItem(item);
return IndexOf(item) != -1;
}
// CountItems