summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2015-06-08 14:58:40 -0700
committerMerov Linden <merov@lindenlab.com>2015-06-08 14:58:40 -0700
commit4f9bf22d5fc473aa15dc7f298a93b89ddc30f415 (patch)
tree8f76091d4f5d43319cdc3a93b85a34a4747f5d2f /indra/newview
parentb0e75cc153d6ec18d8987a5322767b548f29926f (diff)
DD-336, DD-359 : WIP : Introduced a reverse lookup table for version folder to listing folder to improve performance
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llmarketplacefunctions.cpp40
-rwxr-xr-xindra/newview/llmarketplacefunctions.h3
2 files changed, 25 insertions, 18 deletions
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index e15014e6b9..3fec9e0da7 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -1665,16 +1665,23 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id, S32 listing_id, cons
mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id, listing_id, version_id, is_listed);
mMarketplaceItems[folder_id].mEditURL = edit_url;
mMarketplaceItems[folder_id].mCountOnHand = count;
+ if (version_id.notNull())
+ {
+ mVersionFolders[version_id] = folder_id;
+ }
return true;
}
bool LLMarketplaceData::deleteListing(const LLUUID& folder_id, bool update)
{
+ LLUUID version_folder = getVersionFolder(folder_id);
+
if (mMarketplaceItems.erase(folder_id) != 1)
{
return false;
}
-
+ mVersionFolders.erase(version_folder);
+
if (update)
{
update_marketplace_category(folder_id, false);
@@ -1698,20 +1705,20 @@ bool LLMarketplaceData::deleteListing(S32 listing_id, bool update)
bool LLMarketplaceData::getActivationState(const LLUUID& folder_id)
{
// Listing folder case
- if (isListed(folder_id))
+ marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id);
+ if (it != mMarketplaceItems.end())
{
- marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id);
return (it->second).mIsActive;
}
- // We need to iterate through the list to check it's not a version folder
- marketplace_items_list_t::iterator it = mMarketplaceItems.begin();
- while (it != mMarketplaceItems.end())
+ // Version folder case
+ version_folders_list_t::iterator it_version = mVersionFolders.find(folder_id);
+ if (it_version != mVersionFolders.end())
{
- if ((it->second).mVersionFolderId == folder_id)
+ marketplace_items_list_t::iterator it = mMarketplaceItems.find(it_version->second);
+ if (it != mMarketplaceItems.end())
{
return (it->second).mIsActive;
}
- it++;
}
return false;
}
@@ -1771,16 +1778,8 @@ bool LLMarketplaceData::isListedAndActive(const LLUUID& folder_id)
bool LLMarketplaceData::isVersionFolder(const LLUUID& folder_id)
{
- marketplace_items_list_t::iterator it = mMarketplaceItems.begin();
- while (it != mMarketplaceItems.end())
- {
- if ((it->second).mVersionFolderId == folder_id)
- {
- return true;
- }
- it++;
- }
- return false;
+ version_folders_list_t::iterator it = mVersionFolders.find(folder_id);
+ return (it != mVersionFolders.end());
}
bool LLMarketplaceData::isInActiveFolder(const LLUUID& obj_id)
@@ -1908,6 +1907,11 @@ bool LLMarketplaceData::setVersionFolderID(const LLUUID& folder_id, const LLUUID
}
(it->second).mVersionFolderId = version_id;
+ mVersionFolders.erase(old_version_id);
+ if (version_id.notNull())
+ {
+ mVersionFolders[version_id] = folder_id;
+ }
if (update)
{
diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h
index 38ffdeb498..26b1ddc579 100755
--- a/indra/newview/llmarketplacefunctions.h
+++ b/indra/newview/llmarketplacefunctions.h
@@ -165,6 +165,7 @@ private:
// * The mListingFolderId is used as a key to this map. It could therefore be taken off the LLMarketplaceTuple objects themselves.
// * The SLM DB however uses mListingId as its primary key and it shows in its API. In the viewer though, the mListingFolderId is what we use to grab an inventory record.
typedef std::map<LLUUID, LLMarketplaceTuple> marketplace_items_list_t;
+typedef std::map<LLUUID, LLUUID> version_folders_list_t;
// Session cache of all Marketplace tuples
// Notes:
@@ -277,6 +278,8 @@ private:
// The cache of SLM data (at last...)
marketplace_items_list_t mMarketplaceItems;
+ // We need a list (version folder -> listing folder) because such reverse lookups are frequent
+ version_folders_list_t mVersionFolders;
};