[InvOpts] Folder View unordered opt pass

This commit is contained in:
Lirusaito
2019-03-22 02:10:43 -04:00
parent 5f1047c574
commit 9f23dcb0c4
8 changed files with 30 additions and 43 deletions

View File

@@ -865,14 +865,12 @@ void LLFolderView::clearSelection()
mSelectThisID.setNull();
}
std::set<LLUUID> LLFolderView::getSelectionList() const
std::unordered_set<LLUUID> LLFolderView::getSelectionList() const
{
std::set<LLUUID> selection;
for (selected_items_t::const_iterator item_it = mSelectedItems.begin();
item_it != mSelectedItems.end();
++item_it)
std::unordered_set<LLUUID> selection;
for (const auto& item : mSelectedItems)
{
selection.insert((*item_it)->getListener()->getUUID());
selection.insert(item->getListener()->getUUID());
}
return selection;
}
@@ -2118,8 +2116,7 @@ LLFolderViewItem* LLFolderView::getItemByID(const LLUUID& id)
return this;
}
std::map<LLUUID, LLFolderViewItem*>::iterator map_it;
map_it = mItemMap.find(id);
auto map_it = mItemMap.find(id);
if (map_it != mItemMap.end())
{
return map_it->second;

View File

@@ -158,7 +158,7 @@ public:
// children, and keeps track of selected objects.
virtual BOOL changeSelection(LLFolderViewItem* selection, BOOL selected);
virtual std::set<LLUUID> getSelectionList() const;
virtual std::unordered_set<LLUUID> getSelectionList() const;
// Make sure if ancestor is selected, descendants are not
void sanitizeSelection();
@@ -330,7 +330,7 @@ protected:
S32 mSignalSelectCallback;
S32 mMinWidth;
S32 mRunningHeight;
std::map<LLUUID, LLFolderViewItem*> mItemMap;
std::unordered_map<LLUUID, LLFolderViewItem*> mItemMap;
LLUUID mSelectThisID; // if non null, select this item
LLHandle<LLPanel> mParentPanel;

View File

@@ -378,10 +378,9 @@ void LLFolderViewItem::setSelectionFromRoot(LLFolderViewItem* selection,
getRoot()->setSelection(selection, openitem, take_keyboard_focus);
}
std::set<LLUUID> LLFolderViewItem::getSelectionList() const
std::unordered_set<LLUUID> LLFolderViewItem::getSelectionList() const
{
std::set<LLUUID> selection;
return selection;
return std::unordered_set<LLUUID>();
}
EInventorySortGroup LLFolderViewItem::getSortGroup() const

View File

@@ -30,6 +30,9 @@
#include "lluiimage.h"
#include "lluictrl.h"
#include <unordered_map>
#include <unordered_set>
class LLFontGL;
class LLFolderView;
class LLFolderViewEventListener;
@@ -218,7 +221,7 @@ public:
virtual void selectItem();
// gets multiple-element selection
virtual std::set<LLUUID> getSelectionList() const;
virtual std::unordered_set<LLUUID> getSelectionList() const;
// Returns true is this object and all of its children can be removed (deleted by user)
virtual BOOL isRemovable();

View File

@@ -107,11 +107,8 @@ bool get_selection_object_uuids(LLFolderView *root, uuid_vec_t& ids)
{
uuid_vec_t results;
//S32 no_object = 0;
std::set<LLUUID> selectedItems = root->getSelectionList();
for(std::set<LLUUID>::iterator it = selectedItems.begin(); it != selectedItems.end(); ++it)
for(const auto& id : root->getSelectionList())
{
const LLUUID& id(*it);
if(id.notNull())
{
results.push_back(id);
@@ -134,12 +131,12 @@ bool LLInventoryAction::doToSelected(LLFolderView* root, std::string action, BOO
if (!root)
return true;
std::set<LLUUID> selected_items = root->getSelectionList();
auto selected_items = root->getSelectionList();
// Prompt the user and check for authorization for some marketplace active listing edits
if (user_confirm && (("delete" == action) || ("cut" == action) || ("rename" == action) || ("properties" == action) || ("task_properties" == action) || ("open" == action)))
{
std::set<LLUUID>::iterator set_iter = std::find_if(selected_items.begin(), selected_items.end(), boost::bind(&depth_nesting_in_marketplace, _1) >= 0);
auto set_iter = std::find_if(selected_items.begin(), selected_items.end(), boost::bind(&depth_nesting_in_marketplace, _1) >= 0);
if (set_iter != selected_items.end())
{
if ("open" == action)
@@ -177,7 +174,7 @@ bool LLInventoryAction::doToSelected(LLFolderView* root, std::string action, BOO
// Copying to the marketplace needs confirmation if nocopy items are involved
if (("copy_to_marketplace_listings" == action))
{
std::set<LLUUID>::iterator set_iter = selected_items.begin();
auto set_iter = selected_items.begin();
if (contains_nocopy_items(*set_iter))
{
LLNotificationsUtil::add("ConfirmCopyToMarketplace", LLSD(), LLSD(), boost::bind(&LLInventoryAction::callback_copySelected, _1, _2, root, action));
@@ -233,8 +230,6 @@ bool LLInventoryAction::doToSelected(LLFolderView* root, std::string action, BOO
LLFloater::setFloaterHost(multi_floaterp);
}
std::set<LLUUID>::iterator set_iter;
// This rather warty piece of code is to allow items to be removed
// from the avatar in a batch, eliminating redundant
@@ -250,9 +245,9 @@ bool LLInventoryAction::doToSelected(LLFolderView* root, std::string action, BOO
}
else
{
for (set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
for (const auto& id : selected_items)
{
LLFolderViewItem* folder_item = root->getItemByID(*set_iter);
LLFolderViewItem* folder_item = root->getItemByID(id);
if(!folder_item) continue;
LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener();
if(!bridge) continue;
@@ -286,10 +281,9 @@ void LLInventoryAction::buildMarketplaceFolders(LLFolderView* root)
return;
}
std::set<LLUUID> selected_items = root->getSelectionList();
for (std::set<LLUUID>::const_iterator set_iter = selected_items.begin(); set_iter != selected_items.end(); ++set_iter)
for (const auto& item : root->getSelectionList())
{
const LLInventoryObject* obj(gInventory.getObject(*set_iter));
const LLInventoryObject* obj(gInventory.getObject(item));
if (!obj) continue;
if (gInventory.isObjectDescendentOf(obj->getParentUUID(), marketplacelistings_id))
{
@@ -522,7 +516,6 @@ struct LLBeginIMSession : public inventory_panel_listener_t
LLInventoryPanel *panel = mPtr;
LLInventoryModel* model = panel->getModel();
if(!model) return true;
std::set<LLUUID> selected_items = panel->getRootFolder()->getSelectionList();
std::string name;
static int session_num = 1;
@@ -534,10 +527,8 @@ struct LLBeginIMSession : public inventory_panel_listener_t
bool fRlvCanStartIM = true;
// [/RLVa:KB]
for (std::set<LLUUID>::const_iterator iter = selected_items.begin(); iter != selected_items.end(); iter++)
for (const auto& item : panel->getRootFolder()->getSelectionList())
{
LLUUID item = *iter;
LLFolderViewItem* folder_item = panel->getRootFolder()->getItemByID(item);
if(folder_item)
@@ -644,7 +635,7 @@ struct LLAttachObject : public inventory_panel_listener_t
LLFolderView* folder = panel->getRootFolder();
if(!folder) return true;
std::set<LLUUID> selected_items = folder->getSelectionList();
auto selected_items = folder->getSelectionList();
LLUUID id = *selected_items.begin();
std::string joint_name = userdata.asString();

View File

@@ -1365,15 +1365,13 @@ bool LLInventoryPanel::isSelectionRemovable()
bool can_delete = false;
if (mFolderRoot.get())
{
std::set<LLUUID> selection_set = mFolderRoot.get()->getSelectionList();
auto selection_set = mFolderRoot.get()->getSelectionList();
if (!selection_set.empty())
{
can_delete = true;
for (std::set<LLUUID>::iterator iter = selection_set.begin();
iter != selection_set.end();
++iter)
for (const auto& id : selection_set)
{
LLFolderViewItem *item = getItemByID(*iter);
LLFolderViewItem *item = getItemByID(id);
const LLFolderViewEventListener* listener =item->getListener();
if (!listener)
{

View File

@@ -1710,7 +1710,7 @@ void LLPanelObjectInventory::updateInventory()
// << " panel UUID: " << panel->mTaskUUID << "\n"
// << " task UUID: " << object->mID << LL_ENDL;
// We're still interested in this task's inventory.
std::set<LLUUID> selected_items;
std::unordered_set<LLUUID> selected_items;
BOOL inventory_has_focus = FALSE;
if (mHaveInventory)
{
@@ -1748,11 +1748,10 @@ void LLPanelObjectInventory::updateInventory()
}
// restore previous selection
std::set<LLUUID>::iterator selection_it;
bool first_item = true;
for (selection_it = selected_items.begin(); selection_it != selected_items.end(); ++selection_it)
for (const auto id : selected_items)
{
LLFolderViewItem* selected_item = mFolders->getItemByID(*selection_it);
LLFolderViewItem* selected_item = mFolders->getItemByID(id);
if (selected_item)
{

View File

@@ -881,7 +881,7 @@ private:
}
LLHandle<LLPanel> mActivePanel;
typedef std::set<LLUUID> selected_items_t;
typedef std::unordered_set<LLUUID> selected_items_t;
selected_items_t mSelectedItems;
/**