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

View File

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

View File

@@ -378,10 +378,9 @@ void LLFolderViewItem::setSelectionFromRoot(LLFolderViewItem* selection,
getRoot()->setSelection(selection, openitem, take_keyboard_focus); 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 std::unordered_set<LLUUID>();
return selection;
} }
EInventorySortGroup LLFolderViewItem::getSortGroup() const EInventorySortGroup LLFolderViewItem::getSortGroup() const

View File

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

View File

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

View File

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

View File

@@ -1710,7 +1710,7 @@ void LLPanelObjectInventory::updateInventory()
// << " panel UUID: " << panel->mTaskUUID << "\n" // << " panel UUID: " << panel->mTaskUUID << "\n"
// << " task UUID: " << object->mID << LL_ENDL; // << " task UUID: " << object->mID << LL_ENDL;
// We're still interested in this task's inventory. // 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; BOOL inventory_has_focus = FALSE;
if (mHaveInventory) if (mHaveInventory)
{ {
@@ -1748,11 +1748,10 @@ void LLPanelObjectInventory::updateInventory()
} }
// restore previous selection // restore previous selection
std::set<LLUUID>::iterator selection_it;
bool first_item = true; 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) if (selected_item)
{ {

View File

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