summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-01-15 23:30:25 +0200
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-01-16 01:28:07 +0200
commit4e705f8886272d02281f2d0bd7cbed7ad7080c00 (patch)
treef03dc30df21ecf900d59aece18f328de7f9992b6 /indra/newview
parentc2c4489dbb690615e071aa463a4ad2af02892274 (diff)
#5275 Optimize hasParcelLandmark
Implemented result caching. hasParcelLandmark can get repeatedly called when performing operations on landmarks en masse, which was causing repeated inventory searches and leads to stalls with large collections of landmarks.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lllandmarkactions.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp
index 741d0622c5..020eab381f 100644
--- a/indra/newview/lllandmarkactions.cpp
+++ b/indra/newview/lllandmarkactions.cpp
@@ -197,12 +197,51 @@ bool LLLandmarkActions::landmarkAlreadyExists()
//static
bool LLLandmarkActions::hasParcelLandmark()
{
+ static LLUUID sLastItemID;
+ static S32 sLastFrame = -1;
+ if (sLastItemID.notNull())
+ {
+ LLInventoryItem* item = gInventory.getItem(sLastItemID);
+ if (item)
+ {
+ LLLandmark* landmark = gLandmarkList.getAsset(item->getAssetUUID());
+ if (landmark)
+ {
+ LLVector3d landmark_global_pos;
+ if (landmark->getGlobalPos(landmark_global_pos)
+ && LLViewerParcelMgr::getInstance()->inAgentParcel(landmark_global_pos))
+ {
+ return true;
+ }
+ }
+ }
+ // Cached landmark does not match current parcel anymore,
+ // repeat inventory search to find a replacement landmark
+ // or to make sure there are none.
+ sLastItemID.setNull();
+ sLastFrame = -1;
+ }
+
+ if (sLastFrame == LLFrameTimer::getFrameCount())
+ {
+ // Ideally this should also check parcel change and landmark additions,
+ // not just frame change.
+ // But should be sufficient to check only frame as this is used
+ // after inventory and parcel operations.
+ return false;
+ }
+ sLastFrame = LLFrameTimer::getFrameCount();
+
LLFirstAgentParcelLandmark get_first_agent_landmark;
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
fetch_landmarks(cats, items, get_first_agent_landmark);
- return !items.empty();
-
+ if (!items.empty())
+ {
+ sLastItemID = items[0]->getUUID();
+ return true;
+ }
+ return false;
}
// *TODO: This could be made more efficient by only fetching the FIRST