Skip to content
Snippets Groups Projects
Commit 6aa1b0eb authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Faster lookup in large inventories via hashmaps

parent 8777548b
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,9 @@ ...@@ -48,6 +48,9 @@
#include "lleventcoro.h" #include "lleventcoro.h"
#include "llcoros.h" #include "llcoros.h"
#include "absl/container/node_hash_map.h"
#include "absl/container/flat_hash_map.h"
class LLInventoryObserver; class LLInventoryObserver;
class LLInventoryObject; class LLInventoryObject;
class LLInventoryItem; class LLInventoryItem;
...@@ -175,13 +178,13 @@ class LLInventoryModel ...@@ -175,13 +178,13 @@ class LLInventoryModel
// the inventory using several different identifiers. // the inventory using several different identifiers.
// mInventory member data is the 'master' list of inventory, and // mInventory member data is the 'master' list of inventory, and
// mCategoryMap and mItemMap store uuid->object mappings. // mCategoryMap and mItemMap store uuid->object mappings.
typedef std::map<LLUUID, LLPointer<LLViewerInventoryCategory> > cat_map_t; typedef absl::flat_hash_map<LLUUID, LLPointer<LLViewerInventoryCategory> > cat_map_t;
typedef std::map<LLUUID, LLPointer<LLViewerInventoryItem> > item_map_t; typedef absl::flat_hash_map<LLUUID, LLPointer<LLViewerInventoryItem> > item_map_t;
cat_map_t mCategoryMap; cat_map_t mCategoryMap;
item_map_t mItemMap; item_map_t mItemMap;
// This last set of indices is used to map parents to children. // This last set of indices is used to map parents to children.
typedef std::map<LLUUID, cat_array_t*> parent_cat_map_t; typedef absl::flat_hash_map<LLUUID, cat_array_t*> parent_cat_map_t;
typedef std::map<LLUUID, item_array_t*> parent_item_map_t; typedef absl::flat_hash_map<LLUUID, item_array_t*> parent_item_map_t;
parent_cat_map_t mParentChildCategoryTree; parent_cat_map_t mParentChildCategoryTree;
parent_item_map_t mParentChildItemTree; parent_item_map_t mParentChildItemTree;
......
...@@ -1722,8 +1722,7 @@ LLFolderViewItem* LLInventoryPanel::getItemByID(const LLUUID& id) ...@@ -1722,8 +1722,7 @@ LLFolderViewItem* LLInventoryPanel::getItemByID(const LLUUID& id)
{ {
LL_RECORD_BLOCK_TIME(FTM_GET_ITEM_BY_ID); LL_RECORD_BLOCK_TIME(FTM_GET_ITEM_BY_ID);
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;
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#include "lluictrlfactory.h" #include "lluictrlfactory.h"
#include <set> #include <set>
#include "absl/container/flat_hash_map.h"
class LLInvFVBridge; class LLInvFVBridge;
class LLInventoryFolderViewModelBuilder; class LLInventoryFolderViewModelBuilder;
class LLInvPanelComplObserver; class LLInvPanelComplObserver;
...@@ -280,7 +282,7 @@ class LLInventoryPanel : public LLPanel ...@@ -280,7 +282,7 @@ class LLInventoryPanel : public LLPanel
LLPointer<LLFolderViewGroupedItemBridge> mGroupedItemBridge; LLPointer<LLFolderViewGroupedItemBridge> mGroupedItemBridge;
Params mParams; // stored copy of parameter block Params mParams; // stored copy of parameter block
std::map<LLUUID, LLFolderViewItem*> mItemMap; absl::flat_hash_map<LLUUID, LLFolderViewItem*> mItemMap;
/** /**
* Pointer to LLInventoryFolderViewModelBuilder. * Pointer to LLInventoryFolderViewModelBuilder.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment