summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerinventory.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-05-26 00:53:11 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-05-29 01:52:15 +0300
commite0b3b7fc3f07e0823726deba920db2ee5c382746 (patch)
tree5cc9ac178ec953691044899f6f99de9804533bd9 /indra/newview/llviewerinventory.cpp
parent0be27809566c1378fa613aa7c42bfd2406a9f764 (diff)
#3729 Reduce inventory memory overhead
UI elements already cache display name, getDisplayName() calls are rare and only come with other calls. For items, any UI calls already engage internal getItem optimizations, so doing getItem in getDisplayName() has negligible performance overhead while avoiding storing a dupplicate of item's name. This also cuts performance overhead from allocations, so it's a net benefit performance wise on first load. System folders do utilize display names that are different from default names, but they are not panel specific, they are global localizations. Store those in the model, not in the bridge. Usage example: LLFolderViewItem::postBuild() already calls getName after getDisplayName(), so getItem will utilize mLastItem either way and the only refresh needed happens if user renames the item. Without the user the update happens only once.
Diffstat (limited to 'indra/newview/llviewerinventory.cpp')
-rw-r--r--indra/newview/llviewerinventory.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index efa3f5cd1e..707b2f1993 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -4,7 +4,7 @@
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
- * Copyright (C) 2014, Linden Research, Inc.
+ * Copyright (C) 2026, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -673,6 +673,25 @@ void LLViewerInventoryCategory::setVersion(S32 version)
mVersion = version;
}
+const std::string& LLViewerInventoryCategory::getDisplayName() const
+{
+ if (mNeedsDisplayNameUpdate)
+ {
+ buildDisplayName();
+ }
+ if (!mDisplayName.empty())
+ {
+ return mDisplayName;
+ }
+ return getName();
+}
+
+void LLViewerInventoryCategory::invalidateDisplayName()
+{
+ mNeedsDisplayNameUpdate = true;
+ mDisplayName.clear();
+}
+
bool LLViewerInventoryCategory::fetch(S32 expiry_seconds)
{
if((VERSION_UNKNOWN == getVersion())
@@ -889,6 +908,34 @@ void LLViewerInventoryCategory::localizeName()
LLLocalizedInventoryItemsDictionary::getInstance()->localizeInventoryObjectName(mName);
}
+void LLViewerInventoryCategory::buildDisplayName() const
+{
+ // Secure and library folders can't be renamed,
+ // so we only need to do this once.
+ mNeedsDisplayNameUpdate = false;
+
+ //"Accessories" inventory category has folder type FT_NONE. So, this folder
+ //can not be detected as protected with LLFolderType::lookupIsProtectedType
+ //
+ // HACK: EXT - 6028 ([HARD CODED]? Inventory > Library > "Accessories" folder)
+ // Translation of Accessories folder in Library inventory folder
+ LLFolderType::EType preferred_type = getPreferredType();
+
+ bool is_accessories = false;
+ if (getName() == "Accessories")
+ {
+ // To ensure that Accessories folder is in Library we have to check its parent folder.
+ const LLUUID& parent_folder_id = getParentUUID();
+ is_accessories = (parent_folder_id == gInventory.getLibraryRootFolderID());
+ }
+
+ if (is_accessories || LLFolderType::lookupIsProtectedType(preferred_type))
+ {
+ // All predefined folders have translations in strings.xml.
+ LLTrans::findString(mDisplayName, std::string("InvFolder ") + getName(), LLSD());
+ }
+}
+
// virtual
bool LLViewerInventoryCategory::unpackMessage(const LLSD& category)
{